Changes in / [2efe4b8:1cdfa82]


Ignore:
Files:
138 added
123 deleted
114 edited

Legend:

Unmodified
Added
Removed
  • doc/LaTeXmacros/common.tex

    r2efe4b8 r1cdfa82  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Sat Feb 17 21:58:43 2018
    14 %% Update Count     : 369
     13%% Last Modified On : Mon Mar 19 17:18:23 2018
     14%% Update Count     : 379
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    101101% index macros
    102102\newcommand{\italic}[1]{\emph{\hyperpage{#1}}}
    103 \newcommand{\definition}[1]{\textbf{\hyperpage{#1}}}
     103\newcommand{\Definition}[1]{\textbf{\hyperpage{#1}}}
    104104\newcommand{\see}[1]{\emph{see}~#1}
    105105
     
    114114\def\impl{\@bsphack\begingroup
    115115          \def\protect##1{\string##1\space}\@sanitize
    116           \@wrxref{|definition}}
     116          \@wrxref{|Definition}}
    117117\newcommand{\indexcode}[1]{{\lstinline$#1$}}
    118118\def\use{\@bsphack\begingroup
     
    124124    \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}
    125125%\newcommand{\use}[1]{\index{#1@{\lstinline$#1$}}}
    126 %\newcommand{\impl}[1]{\index{\protect#1@{\lstinline$\protect#1$}|definition}}
     126%\newcommand{\impl}[1]{\index{\protect#1@{\lstinline$\protect#1$}|Definition}}
    127127
    128128% inline text and lowercase index: \Index{inline and lowercase index text}
     
    148148% Latin abbreviation
    149149\newcommand{\abbrevFont}{\textit}                       % set empty for no italics
     150\@ifundefined{eg}{
    150151\newcommand{\EG}{\abbrevFont{e}.\abbrevFont{g}.}
    151152\newcommand*{\eg}{%
     
    153154                {\@ifnextchar{:}{\EG}%
    154155                        {\EG,\xspace}}%
    155 }%
     156}}{}%
     157\@ifundefined{ie}{
    156158\newcommand{\IE}{\abbrevFont{i}.\abbrevFont{e}.}
    157159\newcommand*{\ie}{%
     
    159161                {\@ifnextchar{:}{\IE}%
    160162                        {\IE,\xspace}}%
    161 }%
     163}}{}%
     164\@ifundefined{etc}{
    162165\newcommand{\ETC}{\abbrevFont{etc}}
    163166\newcommand*{\etc}{%
    164167        \@ifnextchar{.}{\ETC}%
    165168        {\ETC.\xspace}%
    166 }%
     169}}{}%
     170\@ifundefined{etal}{
    167171\newcommand{\ETAL}{\abbrevFont{et}~\abbrevFont{al}}
    168172\newcommand*{\etal}{%
    169173        \@ifnextchar{.}{\protect\ETAL}%
    170174                {\protect\ETAL.\xspace}%
    171 }%
     175}}{}%
     176\@ifundefined{viz}{
    172177\newcommand{\VIZ}{\abbrevFont{viz}}
    173178\newcommand*{\viz}{%
    174179        \@ifnextchar{.}{\VIZ}%
    175180                {\VIZ.\xspace}%
    176 }%
     181}}{}%
    177182\makeatother
    178183
  • doc/LaTeXmacros/lstlang.sty

    r2efe4b8 r1cdfa82  
    88%% Created On       : Sat May 13 16:34:42 2017
    99%% Last Modified By : Peter A. Buhr
    10 %% Last Modified On : Wed Aug 30 22:11:14 2017
    11 %% Update Count     : 14
     10%% Last Modified On : Fri Apr  6 23:44:50 2018
     11%% Update Count     : 20
    1212%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1313
     
    3131\lstdefinelanguage{sml} {
    3232        morekeywords= {
    33                 EQUAL, GREATER, LESS, NONE, SOME, abstraction, abstype, and, andalso, array, as, before, bool,
    34                 case, char, datatype, do, else, end, eqtype, exception, exn, false, fn, fun, functor, handle,
    35                 if, in, include, infix, infixr, int, let, list, local, nil, nonfix, not, o, of, op, open,
    36                 option, orelse, overload, print, raise, real, rec, ref, sharing, sig, signature, string, struct,
    37                 structure, substring, then, true, type, unit, val, vector, where, while, with, withtype, word
    38         },
    39         morestring=[b]",
    40         morecomment=[s]{(*}{*)},
     33                EQUAL, GREATER, LESS, NONE, SOME, abstraction, abstype, and, andalso, array, as, before,
     34                bool, case, char, datatype, do, else, end, eqtype, exception, exn, false, fn, fun, functor,
     35                handle, if, in, include, infix, infixr, int, let, list, local, nil, nonfix, not, o, of, op,
     36                open, option, orelse, overload, print, raise, real, rec, ref, sharing, sig, signature,
     37                string, struct, structure, substring, then, true, type, unit, val, vector, where, while,
     38                with, withtype, word
     39    },
     40    morestring=[b]",
     41    morecomment=[s]{(*}{*)},
    4142}
    4243
     
    8283
    8384\lstdefinelanguage{rust}{
     85        % Keywords
    8486        morekeywords=[1]{
    8587                abstract, alignof, as, become, box, break, const, continue, crate, do, else, enum, extern,
    86         false, final, fn, for, if, impl, in, let, loop, macro, match, mod, move, mut, offsetof,
    87         override, priv, proc, pub, pure, ref, return, Self, self, sizeof, static, struct, super,
    88         trait, true, type, typeof, unsafe, unsized, use, virtual, where, while, yield
     88                false, final, fn, for, if, impl, in, let, loop, macro, match, mod, move, mut, offsetof,
     89                override, priv, proc, pub, pure, ref, return, Self, self, sizeof, static, struct, super,
     90                trait, true, type, typeof, unsafe, unsized, use, virtual, where, while, yield
    8991        },
     92        % Strings
    9093        morestring=[b]{"},
     94        % Comments
    9195        comment=[l]{//},
    9296        morecomment=[s]{/*}{*/},
     97        % Options
    9398        sensitive=true
    9499}
    95100
    96 \lstdefinelanguage{Pseudo}{
     101\lstdefinelanguage{pseudo}{
    97102        morekeywords={string,uint,int,bool,float},
    98103        sensitive=true,
     
    107112\lstdefinelanguage{CFA}[ANSI]{C}{
    108113        morekeywords={
    109                 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, __attribute,
    110                 __attribute__, auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__,
    111                 __const, __const__, disable, dtype, enable, __extension__, fallthrough, fallthru,
    112                 finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, _Noreturn, one_t,
    113                 otype, restrict, _Static_assert, throw, throwResume, trait, try, ttype, typeof, __typeof,
    114                 __typeof__, virtual, with, zero_t},
    115         morekeywords=[2]{
    116                 _Atomic, coroutine, is_coroutine, is_monitor, is_thread, monitor, mutex, nomutex, or,
    117                 resume, suspend, thread, _Thread_local, waitfor, when, yield},
     114                _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, __attribute, __attribute__,
     115                auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__, __const, __const__,
     116                coroutine, disable, dtype, enable, __extension__, exception, fallthrough, fallthru, finally,
     117                __float80, float80, __float128, float128, forall, ftype, _Generic, _Imaginary, __imag, __imag__,
     118                inline, __inline, __inline__, __int128, int128, __label__, monitor, mutex, _Noreturn, one_t, or,
     119                otype, restrict, __restrict, __restrict__, __signed, __signed__, _Static_assert, thread,
     120                _Thread_local, throw, throwResume, timeout, trait, try, ttype, typeof, __typeof, __typeof__,
     121                virtual, __volatile, __volatile__, waitfor, when, with, zero_t,
     122    },
    118123        moredirectives={defined,include_next}%
    119124}
  • doc/bibliography/pl.bib

    r2efe4b8 r1cdfa82  
    886886@misc{Cforall,
    887887    key         = {Cforall},
    888     title       = {C$\forall$ Features},
     888    title       = {\textsf{C}{$\mathbf{\forall}$} Features},
    889889    howpublished= {\url{https://plg.uwaterloo.ca/~cforall/features}},
    890890    note        = {Accessed: 2018-01-01},
     
    895895    contributer = {pabuhr@plg},
    896896    author      = {Rodolfo Gabriel Esteves},
    897     title       = {C$\forall$, a Study in Evolutionary Design in Programming Languages},
     897    title       = {\textsf{C}$\mathbf{\forall}$, a Study in Evolutionary Design in Programming Languages},
    898898    school      = {School of Computer Science, University of Waterloo},
    899899    year        = 2004,
     
    10381038    contributer = {pabuhr@plg},
    10391039    author      = {Peter A. Buhr and Glen Ditchfield and David Till and Charles R. Zarnke},
    1040     title       = {{\mbox{\mdseries\sffamily C{$\mathbf{\forall}$}}}\ Users Guide, Version 0.1},
     1040    title       = {\textsf{C}$\mathbf{\forall}$ Users Guide, Version 0.1},
    10411041    institution = {Department of Computer Science, University of Waterloo},
    10421042    address     = {Waterloo, Ontario, Canada, N2L 3G1},
     
    15511551@mastersthesis{Delisle18,
    15521552    author      = {Thierry Delisle },
    1553     title       = {Concurrency in {C}$\mathbf{\forall}$},
     1553    title       = {Concurrency in \textsf{C}$\mathbf{\forall}$},
    15541554    school      = {School of Computer Science, University of Waterloo},
    15551555    year        = 2018,
     
    17171717    contributer = {a3moss@uwaterloo.ca},
    17181718    author      = {Glen Ditchfield},
    1719     title       = {Conversions for {Cforall}},
     1719    title       = {Conversions for \textsf{C}$\mathbf{\forall}$},
    17201720    note        = {\href{http://plg.uwaterloo.ca/~cforall/Conversions/index.html}{http://\-plg.uwaterloo.ca/\-\textasciitilde cforall/\-Conversions/\-index.html}},
    17211721    month       = {Nov},
     
    33953395    contributer = {pabuhr@plg},
    33963396    author      = {Richard C. Bilson},
    3397     title       = {Implementing Overloading and Polymorphism in Cforall},
     3397    title       = {Implementing Overloading and Polymorphism in \textsf{C}$\mathbf{\forall}$},
    33983398    school      = {School of Computer Science, University of Waterloo},
    33993399    year        = 2003,
     
    37423742    publisher   = {Oracle},
    37433743    year        = 2015,
    3744     edition     = {Java SE 8},
     3744    edition     = {{J}ava {SE} 8},
    37453745}
    37463746
     
    59285928
    59295929@mastersthesis{Schluntz17,
     5930    keywords    = {constructors, destructors, tuples},
    59305931    author      = {Robert Schluntz},
    5931     title       = {Resource Management and Tuples in {C}$\mathbf{\forall}$},
     5932    title       = {Resource Management and Tuples in \textsf{C}$\mathbf{\forall}$},
    59325933    school      = {School of Computer Science, University of Waterloo},
    59335934    year        = 2017,
  • doc/papers/concurrency/.gitignore

    r2efe4b8 r1cdfa82  
    33*.pdf
    44*.ps
     5
     6Paper.out.ps
     7WileyNJD-AMA.bst
  • doc/papers/concurrency/Makefile

    r2efe4b8 r1cdfa82  
    33Build = build
    44Figures = figures
    5 Macros = ../../LaTeXmacros
    6 TeXLIB = .:style:annex:${Macros}:${Build}:../../bibliography:
     5Macros = ../AMA/AMA-stix/ama
     6TeXLIB = .:annex:../../LaTeXmacros:${Macros}:${Build}:../../bibliography:
    77LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error -output-directory=${Build}
    88BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex
    99
    10 MAKEFLAGS = --no-print-directory --silent #
     10MAKEFLAGS = --no-print-directory # --silent
    1111VPATH = ${Build} ${Figures}
    1212
     
    4040
    4141DOCUMENT = Paper.pdf
     42BASE = ${basename ${DOCUMENT}}
    4243
    4344# Directives #
     
    4849
    4950clean :
    50         @rm -frv ${DOCUMENT} ${basename ${DOCUMENT}}.ps ${Build}
     51        @rm -frv ${DOCUMENT} ${BASE}.ps WileyNJD-AMA.bst ${BASE}.out.ps ${Build}
    5152
    5253# File Dependencies #
    5354
    54 ${DOCUMENT} : ${basename ${DOCUMENT}}.ps
     55${DOCUMENT} : ${BASE}.ps
    5556        ps2pdf $<
    5657
    57 ${basename ${DOCUMENT}}.ps : ${basename ${DOCUMENT}}.dvi
     58${BASE}.ps : ${BASE}.dvi
    5859        dvips ${Build}/$< -o $@
    5960
    60 ${basename ${DOCUMENT}}.dvi : Makefile ${Build} ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
    61                 ${Macros}/common.tex ${Macros}/indexstyle annex/local.bib ../../bibliography/pl.bib
     61${BASE}.dvi : Makefile ${Build} ${BASE}.out.ps WileyNJD-AMA.bst ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
     62                annex/local.bib ../../bibliography/pl.bib
    6263        # Must have *.aux file containing citations for bibtex
    6364        if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi
    64         -${BibTeX} ${Build}/${basename $@}
     65        ${BibTeX} ${Build}/${basename $@}
    6566        # Some citations reference others so run again to resolve these citations
    6667        ${LaTeX} ${basename $@}.tex
    67         -${BibTeX} ${Build}/${basename $@}
     68        ${BibTeX} ${Build}/${basename $@}
    6869        # Run again to finish citations
    6970        ${LaTeX} ${basename $@}.tex
     
    7374${Build}:
    7475        mkdir -p ${Build}
     76
     77${BASE}.out.ps:
     78        ln -fs build/Paper.out.ps .
     79
     80WileyNJD-AMA.bst:
     81        ln -fs ../AMA/AMA-stix/ama/WileyNJD-AMA.bst .
    7582
    7683%.tex : %.fig
  • doc/papers/concurrency/Paper.tex

    r2efe4b8 r1cdfa82  
    1 % inline code ©...© (copyright symbol) emacs: C-q M-)
    2 % red highlighting ®...® (registered trademark symbol) emacs: C-q M-.
    3 % blue highlighting ß...ß (sharp s symbol) emacs: C-q M-_
    4 % green highlighting ¢...¢ (cent symbol) emacs: C-q M-"
    5 % LaTex escape §...§ (section symbol) emacs: C-q M-'
    6 % keyword escape ¶...¶ (pilcrow symbol) emacs: C-q M-^
    7 % math escape $...$ (dollar symbol)
    8 
    9 \documentclass[10pt]{article}
     1\documentclass[AMA,STIX1COL]{WileyNJD-v2}
     2
     3\articletype{RESEARCH ARTICLE}%
     4
     5\received{26 April 2016}
     6\revised{6 June 2016}
     7\accepted{6 June 2016}
     8
     9\raggedbottom
    1010
    1111%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1212
    1313% Latex packages used in the document.
    14 \usepackage[T1]{fontenc}                                        % allow Latin1 (extended ASCII) characters
    15 \usepackage{textcomp}
    16 \usepackage[latin1]{inputenc}
    17 \usepackage{fullpage,times,comment}
     14
    1815\usepackage{epic,eepic}
     16\usepackage{xspace}
     17\usepackage{comment}
    1918\usepackage{upquote}                                            % switch curled `'" to straight
    20 \usepackage{calc}
    21 \usepackage{xspace}
    22 \usepackage[labelformat=simple]{subfig}
    23 \renewcommand{\thesubfigure}{(\alph{subfigure})}
    24 \usepackage{graphicx}
    25 \usepackage{tabularx}
    26 \usepackage{multicol}
    27 \usepackage{varioref}
    2819\usepackage{listings}                                           % format program code
    29 \usepackage[flushmargin]{footmisc}                              % support label/reference in footnote
    30 \usepackage{latexsym}                                           % \Box glyph
    31 \usepackage{mathptmx}                                           % better math font with "times"
    32 \usepackage[usenames]{color}
     20\usepackage[labelformat=simple,aboveskip=0pt,farskip=0pt]{subfig}
     21\renewcommand{\thesubfigure}{(\Alph{subfigure})}
     22\captionsetup{justification=raggedright,singlelinecheck=false}
     23\usepackage{siunitx}
     24\sisetup{ binary-units=true }
     25
     26\hypersetup{breaklinks=true}
     27\definecolor{OliveGreen}{cmyk}{0.64 0 0.95 0.40}
     28\definecolor{Mahogany}{cmyk}{0 0.85 0.87 0.35}
     29\definecolor{Plum}{cmyk}{0.50 1 0 0}
     30
    3331\usepackage[pagewise]{lineno}
    3432\renewcommand{\linenumberfont}{\scriptsize\sffamily}
    35 \usepackage{fancyhdr}
    36 \usepackage{float}
    37 \usepackage{siunitx}
    38 \sisetup{ binary-units=true }
    39 \input{style}                                                   % bespoke macros used in the document
    40 \usepackage{url}
    41 \usepackage[dvips,plainpages=false,pdfpagelabels,pdfpagemode=UseNone,colorlinks=true,pagebackref=true,linkcolor=blue,citecolor=blue,urlcolor=blue,pagebackref=true,breaklinks=true]{hyperref}
    42 \usepackage{breakurl}
    43 \urlstyle{rm}
    44 
    45 \setlength{\topmargin}{-0.45in}                         % move running title into header
    46 \setlength{\headsep}{0.25in}
     33
     34\renewcommand{\textfraction}{0.0}       % the entire page maybe devoted to floats with no text on the page at all
     35
     36\lefthyphenmin=3                                                        % hyphen only after 4 characters
     37\righthyphenmin=3
    4738
    4839%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    5041% Names used in the document.
    5142
    52 \newcommand{\Version}{1.0.0}
    53 \newcommand{\CS}{C\raisebox{-0.9ex}{\large$^\sharp$}\xspace}
     43\newcommand{\CFAIcon}{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name
     44\newcommand{\CFA}{\protect\CFAIcon}             % safe for section/caption
     45\newcommand{\CFL}{\textrm{Cforall}\xspace}      % Cforall symbolic name
     46\newcommand{\Celeven}{\textrm{C11}\xspace}      % C11 symbolic name
     47\newcommand{\CC}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name
     48\newcommand{\CCeleven}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name
     49\newcommand{\CCfourteen}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}14\xspace} % C++14 symbolic name
     50\newcommand{\CCseventeen}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}17\xspace} % C++17 symbolic name
     51\newcommand{\CCtwenty}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}20\xspace} % C++20 symbolic name
     52\newcommand{\Csharp}{C\raisebox{-0.7ex}{\Large$^\sharp$}\xspace} % C# symbolic name
     53
     54%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    5455
    5556\newcommand{\Textbf}[2][red]{{\color{#1}{\textbf{#2}}}}
     
    6263\newcommand{\TODO}{{\Textbf{TODO}}}
    6364
    64 
    65 \newsavebox{\LstBox}
    66 
    6765%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    6866
    69 \setcounter{secnumdepth}{2}                           % number subsubsections
    70 \setcounter{tocdepth}{2}                              % subsubsections in table of contents
    71 % \linenumbers                                          % comment out to turn off line numbering
    72 
    73 \title{Concurrency in \CFA}
    74 \author{Thierry Delisle and Peter A. Buhr, Waterloo, Ontario, Canada}
     67% Default underscore is too low and wide. Cannot use lstlisting "literate" as replacing underscore
     68% removes it as a variable-name character so keywords in variables are highlighted. MUST APPEAR
     69% AFTER HYPERREF.
     70%\DeclareTextCommandDefault{\textunderscore}{\leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.1ex}}}
     71\renewcommand{\textunderscore}{\leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.075ex}}}
     72
     73\makeatletter
     74% parindent is relative, i.e., toggled on/off in environments like itemize, so store the value for
     75% use rather than use \parident directly.
     76\newlength{\parindentlnth}
     77\setlength{\parindentlnth}{\parindent}
     78
     79\newcommand{\LstBasicStyle}[1]{{\lst@basicstyle{\lst@basicstyle{#1}}}}
     80\newcommand{\LstKeywordStyle}[1]{{\lst@basicstyle{\lst@keywordstyle{#1}}}}
     81\newcommand{\LstCommentStyle}[1]{{\lst@basicstyle{\lst@commentstyle{#1}}}}
     82
     83\newlength{\gcolumnposn}                                        % temporary hack because lstlisting does not handle tabs correctly
     84\newlength{\columnposn}
     85\setlength{\gcolumnposn}{3.5in}
     86\setlength{\columnposn}{\gcolumnposn}
     87\newcommand{\C}[2][\@empty]{\ifx#1\@empty\else\global\setlength{\columnposn}{#1}\global\columnposn=\columnposn\fi\hfill\makebox[\textwidth-\columnposn][l]{\lst@basicstyle{\LstCommentStyle{#2}}}}
     88\newcommand{\CRT}{\global\columnposn=\gcolumnposn}
     89
     90% Denote newterms in particular font and index them without particular font and in lowercase, e.g., \newterm{abc}.
     91% The option parameter provides an index term different from the new term, e.g., \newterm[\texttt{abc}]{abc}
     92% The star version does not lowercase the index information, e.g., \newterm*{IBM}.
     93\newcommand{\newtermFontInline}{\emph}
     94\newcommand{\newterm}{\@ifstar\@snewterm\@newterm}
     95\newcommand{\@newterm}[2][\@empty]{\lowercase{\def\temp{#2}}{\newtermFontInline{#2}}\ifx#1\@empty\index{\temp}\else\index{#1@{\protect#2}}\fi}
     96\newcommand{\@snewterm}[2][\@empty]{{\newtermFontInline{#2}}\ifx#1\@empty\index{#2}\else\index{#1@{\protect#2}}\fi}
     97
     98% Latin abbreviation
     99\newcommand{\abbrevFont}{\textit}                       % set empty for no italics
     100\@ifundefined{eg}{
     101\newcommand{\EG}{\abbrevFont{e}\abbrevFont{g}}
     102\newcommand*{\eg}{%
     103        \@ifnextchar{,}{\EG}%
     104                {\@ifnextchar{:}{\EG}%
     105                        {\EG,\xspace}}%
     106}}{}%
     107\@ifundefined{ie}{
     108\newcommand{\IE}{\abbrevFont{i}\abbrevFont{e}}
     109\newcommand*{\ie}{%
     110        \@ifnextchar{,}{\IE}%
     111                {\@ifnextchar{:}{\IE}%
     112                        {\IE,\xspace}}%
     113}}{}%
     114\@ifundefined{etc}{
     115\newcommand{\ETC}{\abbrevFont{etc}}
     116\newcommand*{\etc}{%
     117        \@ifnextchar{.}{\ETC}%
     118        {\ETC.\xspace}%
     119}}{}%
     120\@ifundefined{etal}{
     121\newcommand{\ETAL}{\abbrevFont{et}~\abbrevFont{al}}
     122\newcommand*{\etal}{%
     123        \@ifnextchar{.}{\protect\ETAL}%
     124                {\protect\ETAL.\xspace}%
     125}}{}%
     126\@ifundefined{viz}{
     127\newcommand{\VIZ}{\abbrevFont{viz}}
     128\newcommand*{\viz}{%
     129        \@ifnextchar{.}{\VIZ}%
     130                {\VIZ.\xspace}%
     131}}{}%
     132\makeatother
     133
     134\newenvironment{cquote}{%
     135        \list{}{\lstset{resetmargins=true,aboveskip=0pt,belowskip=0pt}\topsep=3pt\parsep=0pt\leftmargin=\parindentlnth\rightmargin\leftmargin}%
     136        \item\relax
     137}{%
     138        \endlist
     139}% cquote
     140
     141% CFA programming language, based on ANSI C (with some gcc additions)
     142\lstdefinelanguage{CFA}[ANSI]{C}{
     143        morekeywords={
     144                _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, __attribute, __attribute__,
     145                auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__, __const, __const__,
     146                coroutine, disable, dtype, enable, exception, __extension__, fallthrough, fallthru, finally,
     147                __float80, float80, __float128, float128, forall, ftype, _Generic, _Imaginary, __imag, __imag__,
     148                inline, __inline, __inline__, __int128, int128, __label__, monitor, mutex, _Noreturn, one_t, or,
     149                otype, restrict, __restrict, __restrict__, __signed, __signed__, _Static_assert, thread,
     150                _Thread_local, throw, throwResume, timeout, trait, try, ttype, typeof, __typeof, __typeof__,
     151                virtual, __volatile, __volatile__, waitfor, when, with, zero_t},
     152        moredirectives={defined,include_next}%
     153}
     154
     155\lstset{
     156language=CFA,
     157columns=fullflexible,
     158basicstyle=\linespread{0.9}\sf,                                                 % reduce line spacing and use sanserif font
     159stringstyle=\tt,                                                                                % use typewriter font
     160tabsize=5,                                                                                              % N space tabbing
     161xleftmargin=\parindentlnth,                                                             % indent code to paragraph indentation
     162%mathescape=true,                                                                               % LaTeX math escape in CFA code $...$
     163escapechar=\$,                                                                                  % LaTeX escape in CFA code
     164keepspaces=true,                                                                                %
     165showstringspaces=false,                                                                 % do not show spaces with cup
     166showlines=true,                                                                                 % show blank lines at end of code
     167aboveskip=4pt,                                                                                  % spacing above/below code block
     168belowskip=3pt,
     169% replace/adjust listing characters that look bad in sanserif
     170literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.1ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptstyle\land\,$}}1
     171        {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 % {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1
     172        {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex{\textgreater}}2,
     173moredelim=**[is][\color{red}]{`}{`},
     174}% lstset
     175
     176% uC++ programming language, based on ANSI C++
     177\lstdefinelanguage{uC++}[ANSI]{C++}{
     178        morekeywords={
     179                _Accept, _AcceptReturn, _AcceptWait, _Actor, _At, _CatchResume, _Cormonitor, _Coroutine, _Disable,
     180                _Else, _Enable, _Event, _Finally, _Monitor, _Mutex, _Nomutex, _PeriodicTask, _RealTimeTask,
     181                _Resume, _Select, _SporadicTask, _Task, _Timeout, _When, _With, _Throw},
     182}
     183\lstdefinelanguage{Golang}{
     184        morekeywords=[1]{package,import,func,type,struct,return,defer,panic,recover,select,var,const,iota,},
     185        morekeywords=[2]{string,uint,uint8,uint16,uint32,uint64,int,int8,int16,int32,int64,
     186                bool,float32,float64,complex64,complex128,byte,rune,uintptr, error,interface},
     187        morekeywords=[3]{map,slice,make,new,nil,len,cap,copy,close,true,false,delete,append,real,imag,complex,chan,},
     188        morekeywords=[4]{for,break,continue,range,goto,switch,case,fallthrough,if,else,default,},
     189        morekeywords=[5]{Println,Printf,Error,},
     190        sensitive=true,
     191        morecomment=[l]{//},
     192        morecomment=[s]{/*}{*/},
     193        morestring=[b]',
     194        morestring=[b]",
     195        morestring=[s]{`}{`},
     196}
     197
     198\lstnewenvironment{cfa}[1][]
     199{\lstset{#1}}
     200{}
     201\lstnewenvironment{C++}[1][]                            % use C++ style
     202{\lstset{language=C++,moredelim=**[is][\protect\color{red}]{`}{`},#1}\lstset{#1}}
     203{}
     204\lstnewenvironment{uC++}[1][]
     205{\lstset{#1}}
     206{}
     207\lstnewenvironment{Go}[1][]
     208{\lstset{#1}}
     209{}
     210
     211% inline code @...@
     212\lstMakeShortInline@%
     213
     214
     215\title{\texorpdfstring{Concurrency in \protect\CFA}{Concurrency in Cforall}}
     216
     217\author[1]{Thierry Delisle}
     218\author[1]{Peter A. Buhr*}
     219\authormark{DELISLE \textsc{et al.}}
     220
     221\address[1]{\orgdiv{Cheriton School of Computer Science}, \orgname{University of Waterloo}, \orgaddress{\state{Waterloo, ON}, \country{Canada}}}
     222
     223\corres{*Peter A. Buhr, Cheriton School of Computer Science, University of Waterloo, 200 University Avenue West, Waterloo, ON, N2L 3G1, Canada. \email{pabuhr{\char`\@}uwaterloo.ca}}
     224
     225\fundingInfo{Natural Sciences and Engineering Research Council of Canada}
     226
     227\abstract[Summary]{
     228\CFA is a modern, polymorphic, \emph{non-object-oriented} extension of the C programming language.
     229This paper discusses the design of the concurrency and parallelism features in \CFA, and the concurrent runtime-system.
     230These features are created from scratch as ISO C lacks concurrency, relying largely on pthreads library.
     231Coroutines and lightweight (user) threads are introduced into the language.
     232In addition, monitors are added as a high-level mechanism for mutual exclusion and synchronization.
     233A unique contribution is allowing multiple monitors to be safely acquired simultaneously.
     234All features respect the expectations of C programmers, while being fully integrate with the \CFA polymorphic type-system and other language features.
     235Finally, experimental results are presented to compare the performance of the new features with similar mechanisms in other concurrent programming-languages.
     236}%
     237
     238\keywords{concurrency, parallelism, coroutines, threads, monitors, runtime, C, Cforall}
    75239
    76240
    77241\begin{document}
     242\linenumbers                                            % comment out to turn off line numbering
     243
    78244\maketitle
    79245
    80 \begin{abstract}
    81 \CFA is a modern, \emph{non-object-oriented} extension of the C programming language.
    82 This paper serves as a definition and an implementation for the concurrency and parallelism \CFA offers. These features are created from scratch due to the lack of concurrency in ISO C. Lightweight threads are introduced into the language. In addition, monitors are introduced as a high-level tool for control-flow based synchronization and mutual-exclusion. The main contributions of this paper are two-fold: it extends the existing semantics of monitors introduce by~\cite{Hoare74} to handle monitors in groups and also details the engineering effort needed to introduce these features as core language features. Indeed, these features are added with respect to expectations of C programmers, and integrate with the \CFA type-system and other language features.
    83 \end{abstract}
    84 
    85 %----------------------------------------------------------------------
    86 % MAIN BODY
    87 %----------------------------------------------------------------------
    88 
     246% ======================================================================
    89247% ======================================================================
    90248\section{Introduction}
    91249% ======================================================================
    92 
    93 This paper provides a minimal concurrency \textbf{api} that is simple, efficient and can be reused to build higher-level features. The simplest possible concurrency system is a thread and a lock but this low-level approach is hard to master. An easier approach for users is to support higher-level constructs as the basis of concurrency. Indeed, for highly productive concurrent programming, high-level approaches are much more popular~\cite{HPP:Study}. Examples are task based, message passing and implicit threading. The high-level approach and its minimal \textbf{api} are tested in a dialect of C, called \CFA. Furthermore, the proposed \textbf{api} doubles as an early definition of the \CFA language and library. This paper also provides an implementation of the concurrency library for \CFA as well as all the required language features added to the source-to-source translator.
    94 
    95 There are actually two problems that need to be solved in the design of concurrency for a programming language: which concurrency and which parallelism tools are available to the programmer. While these two concepts are often combined, they are in fact distinct, requiring different tools~\cite{Buhr05a}. Concurrency tools need to handle mutual exclusion and synchronization, while parallelism tools are about performance, cost and resource utilization.
    96 
    97 In the context of this paper, a \textbf{thread} is a fundamental unit of execution that runs a sequence of code, generally on a program stack. Having multiple simultaneous threads gives rise to concurrency and generally requires some kind of locking mechanism to ensure proper execution. Correspondingly, \textbf{concurrency} is defined as the concepts and challenges that occur when multiple independent (sharing memory, timing dependencies, etc.) concurrent threads are introduced. Accordingly, \textbf{locking} (and by extension locks) are defined as a mechanism that prevents the progress of certain threads in order to avoid problems due to concurrency. Finally, in this paper \textbf{parallelism} is distinct from concurrency and is defined as running multiple threads simultaneously. More precisely, parallelism implies \emph{actual} simultaneous execution as opposed to concurrency which only requires \emph{apparent} simultaneous execution. As such, parallelism is only observable in the differences in performance or, more generally, differences in timing.
     250% ======================================================================
     251
     252This paper provides a minimal concurrency \newterm{Abstract Program Interface} (API) that is simple, efficient and can be used to build other concurrency features.
     253While the simplest concurrency system is a thread and a lock, this low-level approach is hard to master.
     254An easier approach for programmers is to support higher-level constructs as the basis of concurrency.
     255Indeed, for highly productive concurrent programming, high-level approaches are much more popular~\cite{Hochstein05}.
     256Examples of high-level approaches are task based~\cite{TBB}, message passing~\cite{Erlang,MPI}, and implicit threading~\cite{OpenMP}.
     257
     258This paper uses the following terminology.
     259A \newterm{thread} is a fundamental unit of execution that runs a sequence of code and requires a stack to maintain state.
     260Multiple simultaneous threads give rise to \newterm{concurrency}, which requires locking to ensure safe communication and access to shared data.
     261% Correspondingly, concurrency is defined as the concepts and challenges that occur when multiple independent (sharing memory, timing dependencies, \etc) concurrent threads are introduced.
     262\newterm{Locking}, and by extension locks, are defined as a mechanism to prevent progress of threads to provide safety.
     263\newterm{Parallelism} is running multiple threads simultaneously.
     264Parallelism implies \emph{actual} simultaneous execution, where concurrency only requires \emph{apparent} simultaneous execution.
     265As such, parallelism only affects performance, which is observed through differences in space and/or time.
     266
     267Hence, there are two problems to be solved in the design of concurrency for a programming language: concurrency and parallelism.
     268While these two concepts are often combined, they are distinct, requiring different tools~\cite[\S~2]{Buhr05a}.
     269Concurrency tools handle synchronization and mutual exclusion, while parallelism tools handle performance, cost and resource utilization.
     270
     271The proposed concurrency API is implemented in a dialect of C, called \CFA.
     272The paper discusses how the language features are added to the \CFA translator with respect to parsing, semantic, and type checking, and the corresponding high-perforamnce runtime-library to implement the concurrency features.
    98273
    99274% ======================================================================
     
    104279
    105280The following is a quick introduction to the \CFA language, specifically tailored to the features needed to support concurrency.
    106 
    107 \CFA is an extension of ISO-C and therefore supports all of the same paradigms as C. It is a non-object-oriented system-language, meaning most of the major abstractions have either no runtime overhead or can be opted out easily. Like C, the basics of \CFA revolve around structures and routines, which are thin abstractions over machine code. The vast majority of the code produced by the \CFA translator respects memory layouts and calling conventions laid out by C. Interestingly, while \CFA is not an object-oriented language, lacking the concept of a receiver (e.g., {\tt this}), it does have some notion of objects\footnote{C defines the term objects as : ``region of data storage in the execution environment, the contents of which can represent
    108 values''~\cite[3.15]{C11}}, most importantly construction and destruction of objects. Most of the following code examples can be found on the \CFA website~\cite{www-cfa}.
    109 
    110 % ======================================================================
     281Most of the following code examples can be found on the \CFA website~\cite{Cforall}.
     282
     283\CFA is an extension of ISO-C, and therefore, supports all of the same paradigms as C.
     284%It is a non-object-oriented system-language, meaning most of the major abstractions have either no runtime overhead or can be opted out easily.
     285Like C, the basics of \CFA revolve around structures and routines, which are thin abstractions over machine code.
     286The vast majority of the code produced by the \CFA translator respects memory layouts and calling conventions laid out by C.
     287Interestingly, while \CFA is not an object-oriented language, lacking the concept of a receiver (\eg @this@) and inheritance, it does have some notion of objects\footnote{C defines the term objects as : ``region of data storage in the execution environment, the contents of which can represent
     288values''~\cite[3.15]{C11}}, most importantly construction and destruction of objects.
     289
     290
    111291\subsection{References}
    112292
    113 Like \CC, \CFA introduces rebind-able references providing multiple dereferencing as an alternative to pointers. In regards to concurrency, the semantic difference between pointers and references are not particularly relevant, but since this document uses mostly references, here is a quick overview of the semantics:
    114 \begin{cfacode}
    115 int x, *p1 = &x, **p2 = &p1, ***p3 = &p2,
    116         &r1 = x,    &&r2 = r1,   &&&r3 = r2;
    117 ***p3 = 3;                                                      //change x
    118 r3    = 3;                                                      //change x, ***r3
    119 **p3  = ...;                                            //change p1
    120 *p3   = ...;                                            //change p2
    121 int y, z, & ar[3] = {x, y, z};          //initialize array of references
    122 typeof( ar[1]) p;                                       //is int, referenced object type
    123 typeof(&ar[1]) q;                                       //is int &, reference type
    124 sizeof( ar[1]) == sizeof(int);          //is true, referenced object size
    125 sizeof(&ar[1]) == sizeof(int *);        //is true, reference size
    126 \end{cfacode}
     293Like \CC, \CFA introduces rebind-able references providing multiple dereferencing as an alternative to pointers.
     294In regards to concurrency, the semantic difference between pointers and references are not particularly relevant, but since this document uses mostly references, here is a quick overview of the semantics:
     295\begin{cfa}
     296int x, y, z;
     297int * p1 = &x, ** p2 = &p1, *** p3 = &p2,       $\C{// pointers to x}$
     298        & r1 = x,   && r2 = r1, &&& r3 = r2;    $\C{// references to x}$
     299
     300*p1 = 3; **p2 = 3; ***p3 = 3;                           $\C{// change x}$
     301  r1 = 3;    r2 = 3;      r3 = 3;                       $\C{// change x}$
     302**p3 = &y; *p3 = &z;                                            $\C{// change p1, p2}$
     303&&r3 = &y; &r3 = &z;                                            $\C{// change p1, p2}$
     304int & ar[3] = {x, y, z};                                        $\C{// initialize array of references}$
     305
     306typeof( ar[1]) p;                                                       $\C{// is int, referenced object type}$
     307typeof(&ar[1]) q;                                                       $\C{// is int \&, reference type}$
     308sizeof( ar[1]) == sizeof(int);                          $\C{// is true, referenced object size}$
     309sizeof(&ar[1]) == sizeof(int *);                        $\C{// is true, reference size}$
     310\end{cfa}
    127311The important take away from this code example is that a reference offers a handle to an object, much like a pointer, but which is automatically dereferenced for convenience.
    128312
     
    130314\subsection{Overloading}
    131315
    132 Another important feature of \CFA is function overloading as in Java and \CC, where routines with the same name are selected based on the number and type of the arguments. As well, \CFA uses the return type as part of the selection criteria, as in Ada~\cite{Ada}. For routines with multiple parameters and returns, the selection is complex.
    133 \begin{cfacode}
    134 //selection based on type and number of parameters
    135 void f(void);                   //(1)
    136 void f(char);                   //(2)
    137 void f(int, double);    //(3)
    138 f();                                    //select (1)
    139 f('a');                                 //select (2)
    140 f(3, 5.2);                              //select (3)
    141 
    142 //selection based on  type and number of returns
    143 char   f(int);                  //(1)
    144 double f(int);                  //(2)
    145 char   c = f(3);                //select (1)
    146 double d = f(4);                //select (2)
    147 \end{cfacode}
    148 This feature is particularly important for concurrency since the runtime system relies on creating different types to represent concurrency objects. Therefore, overloading is necessary to prevent the need for long prefixes and other naming conventions that prevent name clashes. As seen in section \ref{basics}, routine \code{main} is an example that benefits from overloading.
     316Another important feature of \CFA is function overloading as in Java and \CC, where routines with the same name are selected based on the number and type of the arguments.
     317As well, \CFA uses the return type as part of the selection criteria, as in Ada~\cite{Ada}.
     318For routines with multiple parameters and returns, the selection is complex.
     319\begin{cfa}
     320// selection based on type and number of parameters
     321void f(void);                   $\C{// (1)}$
     322void f(char);                   $\C{// (2)}$
     323void f(int, double);    $\C{// (3)}$
     324f();                                    $\C{// select (1)}$
     325f('a');                                 $\C{// select (2)}$
     326f(3, 5.2);                              $\C{// select (3)}$
     327
     328// selection based on  type and number of returns
     329char   f(int);                  $\C{// (1)}$
     330double f(int);                  $\C{// (2)}$
     331char   c = f(3);                $\C{// select (1)}$
     332double d = f(4);                $\C{// select (2)}$
     333\end{cfa}
     334This feature is particularly important for concurrency since the runtime system relies on creating different types to represent concurrency objects.
     335Therefore, overloading is necessary to prevent the need for long prefixes and other naming conventions that prevent name clashes.
     336As seen in section \ref{basics}, routine @main@ is an example that benefits from overloading.
    149337
    150338% ======================================================================
    151339\subsection{Operators}
    152 Overloading also extends to operators. The syntax for denoting operator-overloading is to name a routine with the symbol of the operator and question marks where the arguments of the operation appear, e.g.:
    153 \begin{cfacode}
    154 int ++? (int op);                       //unary prefix increment
    155 int ?++ (int op);                       //unary postfix increment
    156 int ?+? (int op1, int op2);             //binary plus
    157 int ?<=?(int op1, int op2);             //binary less than
    158 int ?=? (int & op1, int op2);           //binary assignment
    159 int ?+=?(int & op1, int op2);           //binary plus-assignment
     340Overloading also extends to operators.
     341The syntax for denoting operator-overloading is to name a routine with the symbol of the operator and question marks where the arguments of the operation appear, \eg:
     342\begin{cfa}
     343int ++? (int op);                       $\C{// unary prefix increment}$
     344int ?++ (int op);                       $\C{// unary postfix increment}$
     345int ?+? (int op1, int op2);             $\C{// binary plus}$
     346int ?<=?(int op1, int op2);             $\C{// binary less than}$
     347int ?=? (int & op1, int op2);           $\C{// binary assignment}$
     348int ?+=?(int & op1, int op2);           $\C{// binary plus-assignment}$
    160349
    161350struct S {int i, j;};
    162 S ?+?(S op1, S op2) {                           //add two structures
     351S ?+?(S op1, S op2) {                           $\C{// add two structures}$
    163352        return (S){op1.i + op2.i, op1.j + op2.j};
    164353}
    165354S s1 = {1, 2}, s2 = {2, 3}, s3;
    166 s3 = s1 + s2;                                           //compute sum: s3 == {2, 5}
    167 \end{cfacode}
     355s3 = s1 + s2;                                           $\C{// compute sum: s3 == {2, 5}}$
     356\end{cfa}
    168357While concurrency does not use operator overloading directly, this feature is more important as an introduction for the syntax of constructors.
    169358
    170359% ======================================================================
    171360\subsection{Constructors/Destructors}
    172 Object lifetime is often a challenge in concurrency. \CFA uses the approach of giving concurrent meaning to object lifetime as a means of synchronization and/or mutual exclusion. Since \CFA relies heavily on the lifetime of objects, constructors and destructors is a core feature required for concurrency and parallelism. \CFA uses the following syntax for constructors and destructors:
    173 \begin{cfacode}
     361Object lifetime is often a challenge in concurrency. \CFA uses the approach of giving concurrent meaning to object lifetime as a means of synchronization and/or mutual exclusion.
     362Since \CFA relies heavily on the lifetime of objects, constructors and destructors is a core feature required for concurrency and parallelism. \CFA uses the following syntax for constructors and destructors:
     363\begin{cfa}
    174364struct S {
    175365        size_t size;
    176366        int * ia;
    177367};
    178 void ?{}(S & s, int asize) {    //constructor operator
    179         s.size = asize;                         //initialize fields
     368void ?{}(S & s, int asize) {    $\C{// constructor operator}$
     369        s.size = asize;                         $\C{// initialize fields}$
    180370        s.ia = calloc(size, sizeof(S));
    181371}
    182 void ^?{}(S & s) {                              //destructor operator
    183         free(ia);                                       //de-initialization fields
     372void ^?{}(S & s) {                              $\C{// destructor operator}$
     373        free(ia);                                       $\C{// de-initialization fields}$
    184374}
    185375int main() {
    186         S x = {10}, y = {100};          //implicit calls: ?{}(x, 10), ?{}(y, 100)
    187         ...                                                     //use x and y
    188         ^x{};  ^y{};                            //explicit calls to de-initialize
    189         x{20};  y{200};                         //explicit calls to reinitialize
    190         ...                                                     //reuse x and y
    191 }                                                               //implicit calls: ^?{}(y), ^?{}(x)
    192 \end{cfacode}
    193 The language guarantees that every object and all their fields are constructed. Like \CC, construction of an object is automatically done on allocation and destruction of the object is done on deallocation. Allocation and deallocation can occur on the stack or on the heap.
    194 \begin{cfacode}
     376        S x = {10}, y = {100};          $\C{// implicit calls: ?\{\}(x, 10), ?\{\}(y, 100)}$
     377        ...                                                     $\C{// use x and y}$
     378        ^x{};  ^y{};                            $\C{// explicit calls to de-initialize}$
     379        x{20};  y{200};                         $\C{// explicit calls to reinitialize}$
     380        ...                                                     $\C{// reuse x and y}$
     381}                                                               $\C{// implicit calls: \^?\{\}(y), \^?\{\}(x)}$
     382\end{cfa}
     383The language guarantees that every object and all their fields are constructed.
     384Like \CC, construction of an object is automatically done on allocation and destruction of the object is done on deallocation.
     385Allocation and deallocation can occur on the stack or on the heap.
     386\begin{cfa}
    195387{
    196         struct S s = {10};      //allocation, call constructor
     388        struct S s = {10};      $\C{// allocation, call constructor}$
    197389        ...
    198 }                                               //deallocation, call destructor
    199 struct S * s = new();   //allocation, call constructor
     390}                                               $\C{// deallocation, call destructor}$
     391struct S * s = new();   $\C{// allocation, call constructor}$
    200392...
    201 delete(s);                              //deallocation, call destructor
    202 \end{cfacode}
    203 Note that like \CC, \CFA introduces \code{new} and \code{delete}, which behave like \code{malloc} and \code{free} in addition to constructing and destructing objects, after calling \code{malloc} and before calling \code{free}, respectively.
     393delete(s);                              $\C{// deallocation, call destructor}$
     394\end{cfa}
     395Note that like \CC, \CFA introduces @new@ and @delete@, which behave like @malloc@ and @free@ in addition to constructing and destructing objects, after calling @malloc@ and before calling @free@, respectively.
    204396
    205397% ======================================================================
    206398\subsection{Parametric Polymorphism}
    207399\label{s:ParametricPolymorphism}
    208 Routines in \CFA can also be reused for multiple types. This capability is done using the \code{forall} clauses, which allow separately compiled routines to support generic usage over multiple types. For example, the following sum function works for any type that supports construction from 0 and addition:
    209 \begin{cfacode}
    210 //constraint type, 0 and +
     400Routines in \CFA can also be reused for multiple types.
     401This capability is done using the @forall@ clauses, which allow separately compiled routines to support generic usage over multiple types.
     402For example, the following sum function works for any type that supports construction from 0 and addition:
     403\begin{cfa}
     404// constraint type, 0 and +
    211405forall(otype T | { void ?{}(T *, zero_t); T ?+?(T, T); })
    212406T sum(T a[ ], size_t size) {
    213         T total = 0;                            //construct T from 0
     407        T total = 0;                            $\C{// construct T from 0}$
    214408        for(size_t i = 0; i < size; i++)
    215                 total = total + a[i];   //select appropriate +
     409                total = total + a[i];   $\C{// select appropriate +}$
    216410        return total;
    217411}
    218412
    219413S sa[5];
    220 int i = sum(sa, 5);                             //use S's 0 construction and +
    221 \end{cfacode}
    222 
    223 Since writing constraints on types can become cumbersome for more constrained functions, \CFA also has the concept of traits. Traits are named collection of constraints that can be used both instead and in addition to regular constraints:
    224 \begin{cfacode}
     414int i = sum(sa, 5);                             $\C{// use S's 0 construction and +}$
     415\end{cfa}
     416
     417Since writing constraints on types can become cumbersome for more constrained functions, \CFA also has the concept of traits.
     418Traits are named collection of constraints that can be used both instead and in addition to regular constraints:
     419\begin{cfa}
    225420trait summable( otype T ) {
    226         void ?{}(T *, zero_t);          //constructor from 0 literal
    227         T ?+?(T, T);                            //assortment of additions
     421        void ?{}(T *, zero_t);          $\C{// constructor from 0 literal}$
     422        T ?+?(T, T);                            $\C{// assortment of additions}$
    228423        T ?+=?(T *, T);
    229424        T ++?(T *);
    230425        T ?++(T *);
    231426};
    232 forall( otype T | summable(T) ) //use trait
     427forall( otype T | summable(T) ) $\C{// use trait}$
    233428T sum(T a[], size_t size);
    234 \end{cfacode}
    235 
    236 Note that the type use for assertions can be either an \code{otype} or a \code{dtype}. Types declared as \code{otype} refer to ``complete'' objects, i.e., objects with a size, a default constructor, a copy constructor, a destructor and an assignment operator. Using \code{dtype,} on the other hand, has none of these assumptions but is extremely restrictive, it only guarantees the object is addressable.
     429\end{cfa}
     430
     431Note that the type use for assertions can be either an @otype@ or a @dtype@.
     432Types declared as @otype@ refer to ``complete'' objects, \ie objects with a size, a default constructor, a copy constructor, a destructor and an assignment operator.
     433Using @dtype@, on the other hand, has none of these assumptions but is extremely restrictive, it only guarantees the object is addressable.
    237434
    238435% ======================================================================
    239436\subsection{with Clause/Statement}
    240 Since \CFA lacks the concept of a receiver, certain functions end up needing to repeat variable names often. To remove this inconvenience, \CFA provides the \code{with} statement, which opens an aggregate scope making its fields directly accessible (like Pascal).
    241 \begin{cfacode}
     437Since \CFA lacks the concept of a receiver, certain functions end up needing to repeat variable names often.
     438To remove this inconvenience, \CFA provides the @with@ statement, which opens an aggregate scope making its fields directly accessible (like Pascal).
     439\begin{cfa}
    242440struct S { int i, j; };
    243 int mem(S & this) with (this)           //with clause
    244         i = 1;                                                  //this->i
    245         j = 2;                                                  //this->j
     441int mem(S & this) with (this)           $\C{// with clause}$
     442        i = 1;                                                  $\C{// this->i}$
     443        j = 2;                                                  $\C{// this->j}$
    246444}
    247445int foo() {
    248446        struct S1 { ... } s1;
    249447        struct S2 { ... } s2;
    250         with (s1)                                               //with statement
     448        with (s1)                                               $\C{// with statement}$
    251449        {
    252                 //access fields of s1 without qualification
    253                 with (s2)                                       //nesting
     450                // access fields of s1 without qualification
     451                with (s2)                                       $\C{// nesting}$
    254452                {
    255                         //access fields of s1 and s2 without qualification
     453                        // access fields of s1 and s2 without qualification
    256454                }
    257455        }
    258         with (s1, s2)                                   //scopes open in parallel
     456        with (s1, s2)                                   $\C{// scopes open in parallel}$
    259457        {
    260                 //access fields of s1 and s2 without qualification
     458                // access fields of s1 and s2 without qualification
    261459        }
    262460}
    263 \end{cfacode}
    264 
    265 For more information on \CFA see \cite{cforall-ug,rob-thesis,www-cfa}.
     461\end{cfa}
     462
     463For more information on \CFA see \cite{cforall-ug,Schluntz17,www-cfa}.
    266464
    267465% ======================================================================
     
    270468% ======================================================================
    271469% ======================================================================
    272 Before any detailed discussion of the concurrency and parallelism in \CFA, it is important to describe the basics of concurrency and how they are expressed in \CFA user code.
    273 
    274 \section{Basics of concurrency}
    275 At its core, concurrency is based on having multiple call-stacks and scheduling among threads of execution executing on these stacks. Concurrency without parallelism only requires having multiple call stacks (or contexts) for a single thread of execution.
    276 
    277 Execution with a single thread and multiple stacks where the thread is self-scheduling deterministically across the stacks is called coroutining. Execution with a single and multiple stacks but where the thread is scheduled by an oracle (non-deterministic from the thread's perspective) across the stacks is called concurrency.
    278 
    279 Therefore, a minimal concurrency system can be achieved by creating coroutines (see Section \ref{coroutine}), which instead of context-switching among each other, always ask an oracle where to context-switch next. While coroutines can execute on the caller's stack-frame, stack-full coroutines allow full generality and are sufficient as the basis for concurrency. The aforementioned oracle is a scheduler and the whole system now follows a cooperative threading-model (a.k.a., non-preemptive scheduling). The oracle/scheduler can either be a stack-less or stack-full entity and correspondingly require one or two context-switches to run a different coroutine. In any case, a subset of concurrency related challenges start to appear. For the complete set of concurrency challenges to occur, the only feature missing is preemption.
    280 
    281 A scheduler introduces order of execution uncertainty, while preemption introduces uncertainty about where context switches occur. Mutual exclusion and synchronization are ways of limiting non-determinism in a concurrent system. Now it is important to understand that uncertainty is desirable; uncertainty can be used by runtime systems to significantly increase performance and is often the basis of giving a user the illusion that tasks are running in parallel. Optimal performance in concurrent applications is often obtained by having as much non-determinism as correctness allows.
    282 
    283 \section{\protect\CFA's Thread Building Blocks}
    284 One of the important features that are missing in C is threading\footnote{While the C11 standard defines a ``threads.h'' header, it is minimal and defined as optional. As such, library support for threading is far from widespread. At the time of writing the paper, neither \texttt{gcc} nor \texttt{clang} support ``threads.h'' in their respective standard libraries.}. On modern architectures, a lack of threading is unacceptable~\cite{Sutter05, Sutter05b}, and therefore modern programming languages must have the proper tools to allow users to write efficient concurrent programs to take advantage of parallelism. As an extension of C, \CFA needs to express these concepts in a way that is as natural as possible to programmers familiar with imperative languages. And being a system-level language means programmers expect to choose precisely which features they need and which cost they are willing to pay.
    285 
    286 \section{Coroutines: A Stepping Stone}\label{coroutine}
    287 While the main focus of this proposal is concurrency and parallelism, it is important to address coroutines, which are actually a significant building block of a concurrency system. \textbf{Coroutine}s are generalized routines which have predefined points where execution is suspended and can be resumed at a later time. Therefore, they need to deal with context switches and other context-management operations. This proposal includes coroutines both as an intermediate step for the implementation of threads, and a first-class feature of \CFA. Furthermore, many design challenges of threads are at least partially present in designing coroutines, which makes the design effort that much more relevant. The core \textbf{api} of coroutines revolves around two features: independent call-stacks and \code{suspend}/\code{resume}.
    288 
    289 \begin{table}
    290 \begin{center}
    291 \begin{tabular}{c @{\hskip 0.025in}|@{\hskip 0.025in} c @{\hskip 0.025in}|@{\hskip 0.025in} c}
    292 \begin{ccode}[tabsize=2]
    293 //Using callbacks
    294 void fibonacci_func(
    295         int n,
    296         void (*callback)(int)
    297 ) {
    298         int first = 0;
    299         int second = 1;
    300         int next, i;
    301         for(i = 0; i < n; i++)
    302         {
    303                 if(i <= 1)
    304                         next = i;
    305                 else {
    306                         next = f1 + f2;
    307                         f1 = f2;
    308                         f2 = next;
    309                 }
    310                 callback(next);
     470
     471At its core, concurrency is based on having multiple call-stacks and scheduling among threads of execution executing on these stacks.
     472Multiple call stacks (or contexts) and a single thread of execution does \emph{not} imply concurrency.
     473Execution with a single thread and multiple stacks where the thread is deterministically self-scheduling across the stacks is called \newterm{coroutining};
     474execution with a single thread and multiple stacks but where the thread is scheduled by an oracle (non-deterministic from the thread's perspective) across the stacks is called concurrency~\cite[\S~3]{Buhr05a}.
     475Therefore, a minimal concurrency system can be achieved using coroutines (see Section \ref{coroutine}), which instead of context-switching among each other, always defer to an oracle for where to context-switch next.
     476
     477While coroutines can execute on the caller's stack-frame, stack-full coroutines allow full generality and are sufficient as the basis for concurrency.
     478The aforementioned oracle is a scheduler and the whole system now follows a cooperative threading-model (a.k.a., non-preemptive scheduling).
     479The oracle/scheduler can either be a stack-less or stack-full entity and correspondingly require one or two context-switches to run a different coroutine.
     480In any case, a subset of concurrency related challenges start to appear.
     481For the complete set of concurrency challenges to occur, the only feature missing is preemption.
     482
     483A scheduler introduces order of execution uncertainty, while preemption introduces uncertainty about where context switches occur.
     484Mutual exclusion and synchronization are ways of limiting non-determinism in a concurrent system.
     485Now it is important to understand that uncertainty is desirable; uncertainty can be used by runtime systems to significantly increase performance and is often the basis of giving a user the illusion that tasks are running in parallel.
     486Optimal performance in concurrent applications is often obtained by having as much non-determinism as correctness allows.
     487
     488
     489\subsection{\protect\CFA's Thread Building Blocks}
     490
     491One of the important features that are missing in C is threading\footnote{While the C11 standard defines a ``threads.h'' header, it is minimal and defined as optional.
     492As such, library support for threading is far from widespread.
     493At the time of writing the paper, neither \protect\lstinline|gcc| nor \protect\lstinline|clang| support ``threads.h'' in their standard libraries.}.
     494On modern architectures, a lack of threading is unacceptable~\cite{Sutter05, Sutter05b}, and therefore modern programming languages must have the proper tools to allow users to write efficient concurrent programs to take advantage of parallelism.
     495As an extension of C, \CFA needs to express these concepts in a way that is as natural as possible to programmers familiar with imperative languages.
     496And being a system-level language means programmers expect to choose precisely which features they need and which cost they are willing to pay.
     497
     498
     499\subsection{Coroutines: A Stepping Stone}\label{coroutine}
     500
     501While the focus of this proposal is concurrency and parallelism, it is important to address coroutines, which are a significant building block of a concurrency system.
     502\newterm{Coroutine}s are generalized routines with points where execution is suspended and resumed at a later time.
     503Suspend/resume is a context switche and coroutines have other context-management operations.
     504Many design challenges of threads are partially present in designing coroutines, which makes the design effort relevant.
     505The core \textbf{api} of coroutines has two features: independent call-stacks and @suspend@/@resume@.
     506
     507A coroutine handles the class of problems that need to retain state between calls (\eg plugin, device driver, finite-state machine).
     508For example, a problem made easier with coroutines is unbounded generators, \eg generating an infinite sequence of Fibonacci numbers:
     509\begin{displaymath}
     510f(n) = \left \{
     511\begin{array}{ll}
     5120                               & n = 0         \\
     5131                               & n = 1         \\
     514f(n-1) + f(n-2) & n \ge 2       \\
     515\end{array}
     516\right.
     517\end{displaymath}
     518Figure~\ref{f:C-fibonacci} shows conventional approaches for writing a Fibonacci generator in C.
     519
     520Figure~\ref{f:GlobalVariables} illustrates the following problems:
     521unencapsulated global variables necessary to retain state between calls;
     522only one fibonacci generator can run at a time;
     523execution state must be explicitly retained.
     524Figure~\ref{f:ExternalState} addresses these issues:
     525unencapsulated program global variables become encapsulated structure variables;
     526multiple fibonacci generators can run at a time by declaring multiple fibonacci objects;
     527explicit execution state is removed by precomputing the first two Fibonacci numbers and returning $f(n-2)$.
     528
     529\begin{figure}
     530\centering
     531\newbox\myboxA
     532\begin{lrbox}{\myboxA}
     533\begin{lstlisting}[aboveskip=0pt,belowskip=0pt]
     534`int f1, f2, state = 1;`   // single global variables
     535int fib() {
     536        int fn;
     537        `switch ( state )` {  // explicit execution state
     538          case 1: fn = 0;  f1 = fn;  state = 2;  break;
     539          case 2: fn = 1;  f2 = f1;  f1 = fn;  state = 3;  break;
     540          case 3: fn = f1 + f2;  f2 = f1;  f1 = fn;  break;
    311541        }
    312 }
    313 
     542        return fn;
     543}
    314544int main() {
    315         void print_fib(int n) {
    316                 printf("%d\n", n);
     545
     546        for ( int i = 0; i < 10; i += 1 ) {
     547                printf( "%d\n", fib() );
    317548        }
    318 
    319         fibonacci_func(
    320                 10, print_fib
    321         );
    322 
    323 
    324 
    325 }
    326 \end{ccode}&\begin{ccode}[tabsize=2]
    327 //Using output array
    328 void fibonacci_array(
    329         int n,
    330         int* array
    331 ) {
    332         int f1 = 0; int f2 = 1;
    333         int next, i;
    334         for(i = 0; i < n; i++)
    335         {
    336                 if(i <= 1)
    337                         next = i;
    338                 else {
    339                         next = f1 + f2;
    340                         f1 = f2;
    341                         f2 = next;
    342                 }
    343                 array[i] = next;
     549}
     550\end{lstlisting}
     551\end{lrbox}
     552
     553\newbox\myboxB
     554\begin{lrbox}{\myboxB}
     555\begin{lstlisting}[aboveskip=0pt,belowskip=0pt]
     556#define FIB_INIT `{ 0, 1 }`
     557typedef struct { int f2, f1; } Fib;
     558int fib( Fib * f ) {
     559
     560        int ret = f->f2;
     561        int fn = f->f1 + f->f2;
     562        f->f2 = f->f1; f->f1 = fn;
     563
     564        return ret;
     565}
     566int main() {
     567        Fib f1 = FIB_INIT, f2 = FIB_INIT;
     568        for ( int i = 0; i < 10; i += 1 ) {
     569                printf( "%d %d\n", fib( &f1 ), fib( &f2 ) );
    344570        }
    345571}
    346 
    347 
     572\end{lstlisting}
     573\end{lrbox}
     574
     575\subfloat[3 States: global variables]{\label{f:GlobalVariables}\usebox\myboxA}
     576\qquad
     577\subfloat[1 State: external variables]{\label{f:ExternalState}\usebox\myboxB}
     578\caption{C Fibonacci Implementations}
     579\label{f:C-fibonacci}
     580
     581\bigskip
     582
     583\newbox\myboxA
     584\begin{lrbox}{\myboxA}
     585\begin{lstlisting}[aboveskip=0pt,belowskip=0pt]
     586`coroutine` Fib { int fn; };
     587void main( Fib & f ) with( f ) {
     588        int f1, f2;
     589        fn = 0;  f1 = fn;  `suspend()`;
     590        fn = 1;  f2 = f1;  f1 = fn;  `suspend()`;
     591        for ( ;; ) {
     592                fn = f1 + f2;  f2 = f1;  f1 = fn;  `suspend()`;
     593        }
     594}
     595int next( Fib & fib ) with( fib ) {
     596        `resume( fib );`
     597        return fn;
     598}
    348599int main() {
    349         int a[10];
    350 
    351         fibonacci_func(
    352                 10, a
    353         );
    354 
    355         for(int i=0;i<10;i++){
    356                 printf("%d\n", a[i]);
    357         }
    358 
    359 }
    360 \end{ccode}&\begin{ccode}[tabsize=2]
    361 //Using external state
    362 typedef struct {
    363         int f1, f2;
    364 } Iterator_t;
    365 
    366 int fibonacci_state(
    367         Iterator_t* it
    368 ) {
    369         int f;
    370         f = it->f1 + it->f2;
    371         it->f2 = it->f1;
    372         it->f1 = max(f,1);
    373         return f;
    374 }
    375 
    376 
    377 
    378 
    379 
    380 
    381 
    382 int main() {
    383         Iterator_t it={0,0};
    384 
    385         for(int i=0;i<10;i++){
    386                 printf("%d\n",
    387                         fibonacci_state(
    388                                 &it
    389                         );
    390                 );
    391         }
    392 
    393 }
    394 \end{ccode}
    395 \end{tabular}
    396 \end{center}
    397 \caption{Different implementations of a Fibonacci sequence generator in C.}
    398 \label{lst:fibonacci-c}
    399 \end{table}
    400 
    401 A good example of a problem made easier with coroutines is generators, e.g., generating the Fibonacci sequence. This problem comes with the challenge of decoupling how a sequence is generated and how it is used. Listing \ref{lst:fibonacci-c} shows conventional approaches to writing generators in C. All three of these approach suffer from strong coupling. The left and centre approaches require that the generator have knowledge of how the sequence is used, while the rightmost approach requires holding internal state between calls on behalf of the generator and makes it much harder to handle corner cases like the Fibonacci seed.
    402 
    403 Listing \ref{lst:fibonacci-cfa} is an example of a solution to the Fibonacci problem using \CFA coroutines, where the coroutine stack holds sufficient state for the next generation. This solution has the advantage of having very strong decoupling between how the sequence is generated and how it is used. Indeed, this version is as easy to use as the \code{fibonacci_state} solution, while the implementation is very similar to the \code{fibonacci_func} example.
    404 
    405 \begin{figure}
    406 \begin{cfacode}[caption={Implementation of Fibonacci using coroutines},label={lst:fibonacci-cfa}]
    407 coroutine Fibonacci {
    408         int fn; //used for communication
    409 };
    410 
    411 void ?{}(Fibonacci& this) { //constructor
    412         this.fn = 0;
    413 }
    414 
    415 //main automatically called on first resume
    416 void main(Fibonacci& this) with (this) {
    417         int fn1, fn2;           //retained between resumes
    418         fn  = 0;
    419         fn1 = fn;
    420         suspend(this);          //return to last resume
    421 
    422         fn  = 1;
    423         fn2 = fn1;
    424         fn1 = fn;
    425         suspend(this);          //return to last resume
    426 
    427         for ( ;; ) {
    428                 fn  = fn1 + fn2;
    429                 fn2 = fn1;
    430                 fn1 = fn;
    431                 suspend(this);  //return to last resume
    432         }
    433 }
    434 
    435 int next(Fibonacci& this) {
    436         resume(this); //transfer to last suspend
    437         return this.fn;
    438 }
    439 
    440 void main() { //regular program main
    441         Fibonacci f1, f2;
     600        Fib f1, f2;
    442601        for ( int i = 1; i <= 10; i += 1 ) {
    443602                sout | next( f1 ) | next( f2 ) | endl;
    444603        }
    445604}
    446 \end{cfacode}
     605\end{lstlisting}
     606\end{lrbox}
     607\newbox\myboxB
     608\begin{lrbox}{\myboxB}
     609\begin{lstlisting}[aboveskip=0pt,belowskip=0pt]
     610`coroutine` Fib { int ret; };
     611void main( Fib & f ) with( f ) {
     612        int fn, f1 = 1, f2 = 0;
     613        for ( ;; ) {
     614                ret = f2;
     615
     616                fn = f1 + f2;  f2 = f1;  f1 = fn; `suspend();`
     617        }
     618}
     619int next( Fib & fib ) with( fib ) {
     620        `resume( fib );`
     621        return ret;
     622}
     623
     624
     625
     626
     627
     628
     629\end{lstlisting}
     630\end{lrbox}
     631\subfloat[3 States, internal variables]{\label{f:Coroutine3States}\usebox\myboxA}
     632\qquad\qquad
     633\subfloat[1 State, internal variables]{\label{f:Coroutine1State}\usebox\myboxB}
     634\caption{\CFA Coroutine Fibonacci Implementations}
     635\label{f:fibonacci-cfa}
    447636\end{figure}
    448637
    449 Listing \ref{lst:fmt-line} shows the \code{Format} coroutine for restructuring text into groups of character blocks of fixed size. The example takes advantage of resuming coroutines in the constructor to simplify the code and highlights the idea that interesting control flow can occur in the constructor.
     638Figure~\ref{f:Coroutine3States} creates a @coroutine@ type, which provides communication for multiple interface functions, and the \newterm{coroutine main}, which runs on the coroutine stack.
     639\begin{cfa}
     640`coroutine C { char c; int i; _Bool s; };`      $\C{// used for communication}$
     641void ?{}( C & c ) { s = false; }                        $\C{// constructor}$
     642void main( C & cor ) with( cor ) {                      $\C{// actual coroutine}$
     643        while ( ! s ) // process c
     644        if ( v == ... ) s = false;
     645}
     646// interface functions
     647char cont( C & cor, char ch ) { c = ch; resume( cor ); return c; }
     648_Bool stop( C & cor, int v ) { s = true; i = v; resume( cor ); return s; }
     649\end{cfa}
     650
     651encapsulates the Fibonacci state in the  shows is an example of a solution to the Fibonacci problem using \CFA coroutines, where the coroutine stack holds sufficient state for the next generation.
     652This solution has the advantage of having very strong decoupling between how the sequence is generated and how it is used.
     653Indeed, this version is as easy to use as the @fibonacci_state@ solution, while the implementation is very similar to the @fibonacci_func@ example.
     654
     655Figure~\ref{f:fmt-line} shows the @Format@ coroutine for restructuring text into groups of character blocks of fixed size.
     656The example takes advantage of resuming coroutines in the constructor to simplify the code and highlights the idea that interesting control flow can occur in the constructor.
    450657
    451658\begin{figure}
    452 \begin{cfacode}[tabsize=3,caption={Formatting text into lines of 5 blocks of 4 characters.},label={lst:fmt-line}]
    453 //format characters into blocks of 4 and groups of 5 blocks per line
    454 coroutine Format {
    455         char ch;                                                                        //used for communication
    456         int g, b;                                                               //global because used in destructor
     659\begin{cfa}[xleftmargin=4\parindentlnth]
     660`coroutine` Format {
     661        char ch;                                                                $\C{// used for communication}$
     662        int g, b;                                                               $\C{// global because used in destructor}$
    457663};
    458 
    459 void  ?{}(Format& fmt) {
    460         resume( fmt );                                                  //prime (start) coroutine
    461 }
    462 
    463 void ^?{}(Format& fmt) with fmt {
    464         if ( fmt.g != 0 || fmt.b != 0 )
    465         sout | endl;
    466 }
    467 
    468 void main(Format& fmt) with fmt {
    469         for ( ;; ) {                                                    //for as many characters
    470                 for(g = 0; g < 5; g++) {                //groups of 5 blocks
    471                         for(b = 0; b < 4; fb++) {       //blocks of 4 characters
    472                                 suspend();
    473                                 sout | ch;                                      //print character
     664void ?{}( Format & fmt ) { `resume( fmt );` } $\C{// prime (start) coroutine}$
     665void ^?{}( Format & fmt ) with( fmt ) { if ( g != 0 || b != 0 ) sout | endl; }
     666void main( Format & fmt ) with( fmt ) {
     667        for ( ;; ) {                                                    $\C{// for as many characters}$
     668                for ( g = 0; g < 5; g += 1 ) {          $\C{// groups of 5 blocks}$
     669                        for ( b = 0; b < 4; b += 1 ) {  $\C{// blocks of 4 characters}$
     670                                `suspend();`
     671                                sout | ch;                                      $\C{// print character}$
    474672                        }
    475                         sout | "  ";                                    //print block separator
     673                        sout | "  ";                                    $\C{// print block separator}$
    476674                }
    477                 sout | endl;                                            //print group separator
     675                sout | endl;                                            $\C{// print group separator}$
    478676        }
    479677}
    480 
    481 void prt(Format & fmt, char ch) {
     678void prt( Format & fmt, char ch ) {
    482679        fmt.ch = ch;
    483         resume(fmt);
    484 }
    485 
     680        `resume( fmt );`
     681}
    486682int main() {
    487683        Format fmt;
    488684        char ch;
    489         Eof: for ( ;; ) {                                               //read until end of file
    490                 sin | ch;                                                       //read one character
    491                 if(eof(sin)) break Eof;                 //eof ?
    492                 prt(fmt, ch);                                           //push character for formatting
     685        for ( ;; ) {                                                    $\C{// read until end of file}$
     686                sin | ch;                                                       $\C{// read one character}$
     687          if ( eof( sin ) ) break;                              $\C{// eof ?}$
     688                prt( fmt, ch );                                         $\C{// push character for formatting}$
    493689        }
    494690}
    495 \end{cfacode}
     691\end{cfa}
     692\caption{Formatting text into lines of 5 blocks of 4 characters.}
     693\label{f:fmt-line}
    496694\end{figure}
    497695
    498 \subsection{Construction}
    499 One important design challenge for implementing coroutines and threads (shown in section \ref{threads}) is that the runtime system needs to run code after the user-constructor runs to connect the fully constructed object into the system. In the case of coroutines, this challenge is simpler since there is no non-determinism from preemption or scheduling. However, the underlying challenge remains the same for coroutines and threads.
    500 
    501 The runtime system needs to create the coroutine's stack and, more importantly, prepare it for the first resumption. The timing of the creation is non-trivial since users expect both to have fully constructed objects once execution enters the coroutine main and to be able to resume the coroutine from the constructor. There are several solutions to this problem but the chosen option effectively forces the design of the coroutine.
    502 
    503 Furthermore, \CFA faces an extra challenge as polymorphic routines create invisible thunks when cast to non-polymorphic routines and these thunks have function scope. For example, the following code, while looking benign, can run into undefined behaviour because of thunks:
    504 
    505 \begin{cfacode}
    506 //async: Runs function asynchronously on another thread
     696\begin{figure}
     697\centering
     698\lstset{language=CFA,escapechar={},moredelim=**[is][\protect\color{red}]{`}{`}}
     699\begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
     700\begin{cfa}
     701`coroutine` Prod {
     702        Cons & c;
     703        int N, money, receipt;
     704};
     705void main( Prod & prod ) with( prod ) {
     706        // 1st resume starts here
     707        for ( int i = 0; i < N; i += 1 ) {
     708                int p1 = random( 100 ), p2 = random( 100 );
     709                sout | p1 | " " | p2 | endl;
     710                int status = delivery( c, p1, p2 );
     711                sout | " $" | money | endl | status | endl;
     712                receipt += 1;
     713        }
     714        stop( c );
     715        sout | "prod stops" | endl;
     716}
     717int payment( Prod & prod, int money ) {
     718        prod.money = money;
     719        `resume( prod );`
     720        return prod.receipt;
     721}
     722void start( Prod & prod, int N, Cons &c ) {
     723        &prod.c = &c;
     724        prod.[N, receipt] = [N, 0];
     725        `resume( prod );`
     726}
     727int main() {
     728        Prod prod;
     729        Cons cons = { prod };
     730        srandom( getpid() );
     731        start( prod, 5, cons );
     732}
     733\end{cfa}
     734&
     735\begin{cfa}
     736`coroutine` Cons {
     737        Prod & p;
     738        int p1, p2, status;
     739        _Bool done;
     740};
     741void ?{}( Cons & cons, Prod & p ) {
     742        &cons.p = &p;
     743        cons.[status, done ] = [0, false];
     744}
     745void ^?{}( Cons & cons ) {}
     746void main( Cons & cons ) with( cons ) {
     747        // 1st resume starts here
     748        int money = 1, receipt;
     749        for ( ; ! done; ) {
     750                sout | p1 | " " | p2 | endl | " $" | money | endl;
     751                status += 1;
     752                receipt = payment( p, money );
     753                sout | " #" | receipt | endl;
     754                money += 1;
     755        }
     756        sout | "cons stops" | endl;
     757}
     758int delivery( Cons & cons, int p1, int p2 ) {
     759        cons.[p1, p2] = [p1, p2];
     760        `resume( cons );`
     761        return cons.status;
     762}
     763void stop( Cons & cons ) {
     764        cons.done = true;
     765        `resume( cons );`
     766}
     767
     768\end{cfa}
     769\end{tabular}
     770\caption{Producer / consumer: resume-resume cycle, bi-directional communication}
     771\label{f:ProdCons}
     772\end{figure}
     773
     774
     775\subsubsection{Construction}
     776
     777One important design challenge for implementing coroutines and threads (shown in section \ref{threads}) is that the runtime system needs to run code after the user-constructor runs to connect the fully constructed object into the system.
     778In the case of coroutines, this challenge is simpler since there is no non-determinism from preemption or scheduling.
     779However, the underlying challenge remains the same for coroutines and threads.
     780
     781The runtime system needs to create the coroutine's stack and, more importantly, prepare it for the first resumption.
     782The timing of the creation is non-trivial since users expect both to have fully constructed objects once execution enters the coroutine main and to be able to resume the coroutine from the constructor.
     783There are several solutions to this problem but the chosen option effectively forces the design of the coroutine.
     784
     785Furthermore, \CFA faces an extra challenge as polymorphic routines create invisible thunks when cast to non-polymorphic routines and these thunks have function scope.
     786For example, the following code, while looking benign, can run into undefined behaviour because of thunks:
     787
     788\begin{cfa}
     789// async: Runs function asynchronously on another thread
    507790forall(otype T)
    508791extern void async(void (*func)(T*), T* obj);
     
    513796void bar() {
    514797        int a;
    515         async(noop, &a); //start thread running noop with argument a
    516 }
    517 \end{cfacode}
     798        async(noop, &a); // start thread running noop with argument a
     799}
     800\end{cfa}
    518801
    519802The generated C code\footnote{Code trimmed down for brevity} creates a local thunk to hold type information:
    520803
    521 \begin{ccode}
     804\begin{cfa}
    522805extern void async(/* omitted */, void (*func)(void*), void* obj);
    523806
     
    533816        async(/* omitted */, ((void (*)(void*))(&_thunk0)), (&a));
    534817}
    535 \end{ccode}
    536 The problem in this example is a storage management issue, the function pointer \code{_thunk0} is only valid until the end of the block, which limits the viable solutions because storing the function pointer for too long causes undefined behaviour; i.e., the stack-based thunk being destroyed before it can be used. This challenge is an extension of challenges that come with second-class routines. Indeed, GCC nested routines also have the limitation that nested routine cannot be passed outside of the declaration scope. The case of coroutines and threads is simply an extension of this problem to multiple call stacks.
    537 
    538 \subsection{Alternative: Composition}
     818\end{cfa}
     819The problem in this example is a storage management issue, the function pointer @_thunk0@ is only valid until the end of the block, which limits the viable solutions because storing the function pointer for too long causes undefined behaviour; \ie the stack-based thunk being destroyed before it can be used.
     820This challenge is an extension of challenges that come with second-class routines.
     821Indeed, GCC nested routines also have the limitation that nested routine cannot be passed outside of the declaration scope.
     822The case of coroutines and threads is simply an extension of this problem to multiple call stacks.
     823
     824
     825\subsubsection{Alternative: Composition}
     826
    539827One solution to this challenge is to use composition/containment, where coroutine fields are added to manage the coroutine.
    540828
    541 \begin{cfacode}
     829\begin{cfa}
    542830struct Fibonacci {
    543         int fn; //used for communication
    544         coroutine c; //composition
     831        int fn; // used for communication
     832        coroutine c; // composition
    545833};
    546834
     
    551839void ?{}(Fibonacci& this) {
    552840        this.fn = 0;
    553         //Call constructor to initialize coroutine
     841        // Call constructor to initialize coroutine
    554842        (this.c){myMain};
    555843}
    556 \end{cfacode}
    557 The downside of this approach is that users need to correctly construct the coroutine handle before using it. Like any other objects, the user must carefully choose construction order to prevent usage of objects not yet constructed. However, in the case of coroutines, users must also pass to the coroutine information about the coroutine main, like in the previous example. This opens the door for user errors and requires extra runtime storage to pass at runtime information that can be known statically.
    558 
    559 \subsection{Alternative: Reserved keyword}
     844\end{cfa}
     845The downside of this approach is that users need to correctly construct the coroutine handle before using it.
     846Like any other objects, the user must carefully choose construction order to prevent usage of objects not yet constructed.
     847However, in the case of coroutines, users must also pass to the coroutine information about the coroutine main, like in the previous example.
     848This opens the door for user errors and requires extra runtime storage to pass at runtime information that can be known statically.
     849
     850
     851\subsubsection{Alternative: Reserved keyword}
     852
    560853The next alternative is to use language support to annotate coroutines as follows:
    561 
    562 \begin{cfacode}
     854\begin{cfa}
    563855coroutine Fibonacci {
    564         int fn; //used for communication
     856        int fn; // used for communication
    565857};
    566 \end{cfacode}
    567 The \code{coroutine} keyword means the compiler can find and inject code where needed. The downside of this approach is that it makes coroutine a special case in the language. Users wanting to extend coroutines or build their own for various reasons can only do so in ways offered by the language. Furthermore, implementing coroutines without language supports also displays the power of the programming language used. While this is ultimately the option used for idiomatic \CFA code, coroutines and threads can still be constructed by users without using the language support. The reserved keywords are only present to improve ease of use for the common cases.
    568 
    569 \subsection{Alternative: Lambda Objects}
    570 
    571 For coroutines as for threads, many implementations are based on routine pointers or function objects~\cite{Butenhof97, C++14, MS:VisualC++, BoostCoroutines15}. For example, Boost implements coroutines in terms of four functor object types:
    572 \begin{cfacode}
     858\end{cfa}
     859The @coroutine@ keyword means the compiler can find and inject code where needed.
     860The downside of this approach is that it makes coroutine a special case in the language.
     861Users wanting to extend coroutines or build their own for various reasons can only do so in ways offered by the language.
     862Furthermore, implementing coroutines without language supports also displays the power of the programming language used.
     863While this is ultimately the option used for idiomatic \CFA code, coroutines and threads can still be constructed by users without using the language support.
     864The reserved keywords are only present to improve ease of use for the common cases.
     865
     866
     867\subsubsection{Alternative: Lambda Objects}
     868
     869For coroutines as for threads, many implementations are based on routine pointers or function objects~\cite{Butenhof97, C++14, MS:VisualC++, BoostCoroutines15}.
     870For example, Boost implements coroutines in terms of four functor object types:
     871\begin{cfa}
    573872asymmetric_coroutine<>::pull_type
    574873asymmetric_coroutine<>::push_type
    575874symmetric_coroutine<>::call_type
    576875symmetric_coroutine<>::yield_type
    577 \end{cfacode}
    578 Often, the canonical threading paradigm in languages is based on function pointers, \texttt{pthread} being one of the most well-known examples. The main problem of this approach is that the thread usage is limited to a generic handle that must otherwise be wrapped in a custom type. Since the custom type is simple to write in \CFA and solves several issues, added support for routine/lambda based coroutines adds very little.
    579 
    580 A variation of this would be to use a simple function pointer in the same way \texttt{pthread} does for threads:
    581 \begin{cfacode}
     876\end{cfa}
     877Often, the canonical threading paradigm in languages is based on function pointers, @pthread@ being one of the most well-known examples.
     878The main problem of this approach is that the thread usage is limited to a generic handle that must otherwise be wrapped in a custom type.
     879Since the custom type is simple to write in \CFA and solves several issues, added support for routine/lambda based coroutines adds very little.
     880
     881A variation of this would be to use a simple function pointer in the same way @pthread@ does for threads:
     882\begin{cfa}
    582883void foo( coroutine_t cid, void* arg ) {
    583884        int* value = (int*)arg;
    584         //Coroutine body
     885        // Coroutine body
    585886}
    586887
     
    590891        coroutine_resume( &cid );
    591892}
    592 \end{cfacode}
    593 This semantics is more common for thread interfaces but coroutines work equally well. As discussed in section \ref{threads}, this approach is superseded by static approaches in terms of expressivity.
    594 
    595 \subsection{Alternative: Trait-Based Coroutines}
    596 
    597 Finally, the underlying approach, which is the one closest to \CFA idioms, is to use trait-based lazy coroutines. This approach defines a coroutine as anything that satisfies the trait \code{is_coroutine} (as defined below) and is used as a coroutine.
    598 
    599 \begin{cfacode}
     893\end{cfa}
     894This semantics is more common for thread interfaces but coroutines work equally well.
     895As discussed in section \ref{threads}, this approach is superseded by static approaches in terms of expressivity.
     896
     897
     898\subsubsection{Alternative: Trait-Based Coroutines}
     899
     900Finally, the underlying approach, which is the one closest to \CFA idioms, is to use trait-based lazy coroutines.
     901This approach defines a coroutine as anything that satisfies the trait @is_coroutine@ (as defined below) and is used as a coroutine.
     902
     903\begin{cfa}
    600904trait is_coroutine(dtype T) {
    601905      void main(T& this);
     
    605909forall( dtype T | is_coroutine(T) ) void suspend(T&);
    606910forall( dtype T | is_coroutine(T) ) void resume (T&);
    607 \end{cfacode}
    608 This ensures that an object is not a coroutine until \code{resume} is called on the object. Correspondingly, any object that is passed to \code{resume} is a coroutine since it must satisfy the \code{is_coroutine} trait to compile. The advantage of this approach is that users can easily create different types of coroutines, for example, changing the memory layout of a coroutine is trivial when implementing the \code{get_coroutine} routine. The \CFA keyword \code{coroutine} simply has the effect of implementing the getter and forward declarations required for users to implement the main routine.
     911\end{cfa}
     912This ensures that an object is not a coroutine until @resume@ is called on the object.
     913Correspondingly, any object that is passed to @resume@ is a coroutine since it must satisfy the @is_coroutine@ trait to compile.
     914The advantage of this approach is that users can easily create different types of coroutines, for example, changing the memory layout of a coroutine is trivial when implementing the @get_coroutine@ routine.
     915The \CFA keyword @coroutine@ simply has the effect of implementing the getter and forward declarations required for users to implement the main routine.
    609916
    610917\begin{center}
    611918\begin{tabular}{c c c}
    612 \begin{cfacode}[tabsize=3]
     919\begin{cfa}[tabsize=3]
    613920coroutine MyCoroutine {
    614921        int someValue;
    615922};
    616 \end{cfacode} & == & \begin{cfacode}[tabsize=3]
     923\end{cfa} & == & \begin{cfa}[tabsize=3]
    617924struct MyCoroutine {
    618925        int someValue;
     
    628935
    629936void main(struct MyCoroutine* this);
    630 \end{cfacode}
     937\end{cfa}
    631938\end{tabular}
    632939\end{center}
     
    634941The combination of these two approaches allows users new to coroutining and concurrency to have an easy and concise specification, while more advanced users have tighter control on memory layout and initialization.
    635942
    636 \section{Thread Interface}\label{threads}
    637 The basic building blocks of multithreading in \CFA are \textbf{cfathread}. Both user and kernel threads are supported, where user threads are the concurrency mechanism and kernel threads are the parallel mechanism. User threads offer a flexible and lightweight interface. A thread can be declared using a struct declaration \code{thread} as follows:
    638 
    639 \begin{cfacode}
     943\subsection{Thread Interface}\label{threads}
     944The basic building blocks of multithreading in \CFA are \textbf{cfathread}.
     945Both user and kernel threads are supported, where user threads are the concurrency mechanism and kernel threads are the parallel mechanism.
     946User threads offer a flexible and lightweight interface.
     947A thread can be declared using a struct declaration @thread@ as follows:
     948
     949\begin{cfa}
    640950thread foo {};
    641 \end{cfacode}
     951\end{cfa}
    642952
    643953As for coroutines, the keyword is a thin wrapper around a \CFA trait:
    644954
    645 \begin{cfacode}
     955\begin{cfa}
    646956trait is_thread(dtype T) {
    647957      void ^?{}(T & mutex this);
     
    649959      thread_desc* get_thread(T & this);
    650960};
    651 \end{cfacode}
    652 
    653 Obviously, for this thread implementation to be useful it must run some user code. Several other threading interfaces use a function-pointer representation as the interface of threads (for example \Csharp~\cite{Csharp} and Scala~\cite{Scala}). However, this proposal considers that statically tying a \code{main} routine to a thread supersedes this approach. Since the \code{main} routine is already a special routine in \CFA (where the program begins), it is a natural extension of the semantics to use overloading to declare mains for different threads (the normal main being the main of the initial thread). As such the \code{main} routine of a thread can be defined as
    654 \begin{cfacode}
     961\end{cfa}
     962
     963Obviously, for this thread implementation to be useful it must run some user code.
     964Several other threading interfaces use a function-pointer representation as the interface of threads (for example \Csharp~\cite{Csharp} and Scala~\cite{Scala}).
     965However, this proposal considers that statically tying a @main@ routine to a thread supersedes this approach.
     966Since the @main@ routine is already a special routine in \CFA (where the program begins), it is a natural extension of the semantics to use overloading to declare mains for different threads (the normal main being the main of the initial thread).
     967As such the @main@ routine of a thread can be defined as
     968\begin{cfa}
    655969thread foo {};
    656970
     
    658972        sout | "Hello World!" | endl;
    659973}
    660 \end{cfacode}
    661 
    662 In this example, threads of type \code{foo} start execution in the \code{void main(foo &)} routine, which prints \code{"Hello World!".} While this paper encourages this approach to enforce strongly typed programming, users may prefer to use the routine-based thread semantics for the sake of simplicity. With the static semantics it is trivial to write a thread type that takes a function pointer as a parameter and executes it on its stack asynchronously.
    663 \begin{cfacode}
     974\end{cfa}
     975
     976In this example, threads of type @foo@ start execution in the @void main(foo &)@ routine, which prints @"Hello World!".@ While this paper encourages this approach to enforce strongly typed programming, users may prefer to use the routine-based thread semantics for the sake of simplicity.
     977With the static semantics it is trivial to write a thread type that takes a function pointer as a parameter and executes it on its stack asynchronously.
     978\begin{cfa}
    664979typedef void (*voidFunc)(int);
    665980
     
    675990
    676991void main(FuncRunner & this) {
    677         //thread starts here and runs the function
     992        // thread starts here and runs the function
    678993        this.func( this.arg );
    679994}
     
    6871002        return 0?
    6881003}
    689 \end{cfacode}
     1004\end{cfa}
    6901005
    6911006A consequence of the strongly typed approach to main is that memory layout of parameters and return values to/from a thread are now explicitly specified in the \textbf{api}.
    6921007
    693 Of course, for threads to be useful, it must be possible to start and stop threads and wait for them to complete execution. While using an \textbf{api} such as \code{fork} and \code{join} is relatively common in the literature, such an interface is unnecessary. Indeed, the simplest approach is to use \textbf{raii} principles and have threads \code{fork} after the constructor has completed and \code{join} before the destructor runs.
    694 \begin{cfacode}
     1008Of course, for threads to be useful, it must be possible to start and stop threads and wait for them to complete execution.
     1009While using an \textbf{api} such as @fork@ and @join@ is relatively common in the literature, such an interface is unnecessary.
     1010Indeed, the simplest approach is to use \textbf{raii} principles and have threads @fork@ after the constructor has completed and @join@ before the destructor runs.
     1011\begin{cfa}
    6951012thread World;
    6961013
     
    7011018void main() {
    7021019        World w;
    703         //Thread forks here
    704 
    705         //Printing "Hello " and "World!" are run concurrently
     1020        // Thread forks here
     1021
     1022        // Printing "Hello " and "World!" are run concurrently
    7061023        sout | "Hello " | endl;
    7071024
    708         //Implicit join at end of scope
    709 }
    710 \end{cfacode}
     1025        // Implicit join at end of scope
     1026}
     1027\end{cfa}
    7111028
    7121029This semantic has several advantages over explicit semantics: a thread is always started and stopped exactly once, users cannot make any programming errors, and it naturally scales to multiple threads meaning basic synchronization is very simple.
    7131030
    714 \begin{cfacode}
     1031\begin{cfa}
    7151032thread MyThread {
    7161033        //...
    7171034};
    7181035
    719 //main
     1036// main
    7201037void main(MyThread& this) {
    7211038        //...
     
    7241041void foo() {
    7251042        MyThread thrds[10];
    726         //Start 10 threads at the beginning of the scope
     1043        // Start 10 threads at the beginning of the scope
    7271044
    7281045        DoStuff();
    7291046
    730         //Wait for the 10 threads to finish
    731 }
    732 \end{cfacode}
    733 
    734 However, one of the drawbacks of this approach is that threads always form a tree where nodes must always outlive their children, i.e., they are always destroyed in the opposite order of construction because of C scoping rules. This restriction is relaxed by using dynamic allocation, so threads can outlive the scope in which they are created, much like dynamically allocating memory lets objects outlive the scope in which they are created.
    735 
    736 \begin{cfacode}
     1047        // Wait for the 10 threads to finish
     1048}
     1049\end{cfa}
     1050
     1051However, one of the drawbacks of this approach is that threads always form a tree where nodes must always outlive their children, \ie they are always destroyed in the opposite order of construction because of C scoping rules.
     1052This restriction is relaxed by using dynamic allocation, so threads can outlive the scope in which they are created, much like dynamically allocating memory lets objects outlive the scope in which they are created.
     1053
     1054\begin{cfa}
    7371055thread MyThread {
    7381056        //...
     
    7461064        MyThread* long_lived;
    7471065        {
    748                 //Start a thread at the beginning of the scope
     1066                // Start a thread at the beginning of the scope
    7491067                MyThread short_lived;
    7501068
    751                 //create another thread that will outlive the thread in this scope
     1069                // create another thread that will outlive the thread in this scope
    7521070                long_lived = new MyThread;
    7531071
    7541072                DoStuff();
    7551073
    756                 //Wait for the thread short_lived to finish
     1074                // Wait for the thread short_lived to finish
    7571075        }
    7581076        DoMoreStuff();
    7591077
    760         //Now wait for the long_lived to finish
     1078        // Now wait for the long_lived to finish
    7611079        delete long_lived;
    7621080}
    763 \end{cfacode}
     1081\end{cfa}
    7641082
    7651083
     
    7691087% ======================================================================
    7701088% ======================================================================
    771 Several tools 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 closely relate to networking concepts (channels~\cite{CSP,Go} 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 calls). This distinction in turn means that, in order to be effective, programmers need to learn two sets of design patterns. While this distinction can be hidden away in library code, effective use of the library still has to take both paradigms into account.
    772 
    773 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 desirable to have a higher-level construct be the core concurrency paradigm~\cite{HPP:Study}.
    774 
    775 An approach that is worth mentioning because it is gaining in popularity is transactional memory~\cite{Herlihy93}. While this approach is even pursued by system languages like \CC~\cite{Cpp-Transactions}, the performance and feature set is currently too restrictive to be the main concurrency paradigm for system languages, which is why it was rejected as the core paradigm for concurrency in \CFA.
    776 
    777 One 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.
    778 
    779 \section{Basics}
    780 Non-determinism requires concurrent systems to offer support for mutual-exclusion and synchronization. Mutual-exclusion is the concept that only a fixed number of threads can access a critical section at any given time, where a critical section is a group of instructions on an associated portion of data that requires the restricted access. On the other hand, synchronization enforces relative ordering of execution and synchronization tools provide numerous mechanisms to establish timing relationships among threads.
    781 
    782 \subsection{Mutual-Exclusion}
    783 As mentioned above, mutual-exclusion is the guarantee that only a fix number of threads can enter a critical section at once. However, many solutions exist for mutual exclusion, which vary in terms of performance, flexibility and ease of use. Methods range from low-level locks, which are fast and flexible but require significant attention to be correct, to  higher-level concurrency techniques, which sacrifice some performance in order to improve ease of use. Ease of use comes by either guaranteeing some problems cannot occur (e.g., being deadlock free) or by offering a more explicit coupling between data and corresponding critical section. For example, the \CC \code{std::atomic<T>} offers an easy way to express mutual-exclusion on a restricted set of operations (e.g., reading/writing large types atomically). Another challenge with low-level locks is composability. Locks have restricted composability because it takes careful organizing for multiple locks to be used while preventing deadlocks. Easing composability is another feature higher-level mutual-exclusion mechanisms often offer.
    784 
    785 \subsection{Synchronization}
    786 As with mutual-exclusion, low-level synchronization primitives often offer good performance and good flexibility at the cost of ease of use. Again, higher-level mechanisms often simplify usage by adding either better coupling between synchronization and data (e.g., message passing) or offering a simpler solution to otherwise involved challenges. As mentioned above, synchronization can be expressed as guaranteeing that event \textit{X} always happens before \textit{Y}. Most of the time, synchronization happens within a critical section, where threads must acquire mutual-exclusion in a certain order. However, it may also be desirable to guarantee that event \textit{Z} does not occur between \textit{X} and \textit{Y}. Not satisfying this property is called \textbf{barging}. For example, where event \textit{X} tries to effect event \textit{Y} but another thread acquires the critical section and emits \textit{Z} before \textit{Y}. The classic example is the thread that finishes using a resource and unblocks a thread waiting to use the resource, but the unblocked thread must compete to acquire the resource. Preventing or detecting barging is an involved challenge with low-level locks, which can be made much easier by higher-level constructs. This challenge is often split into two different methods, barging avoidance and barging prevention. Algorithms that use flag variables to detect barging threads are said to be using barging avoidance, while algorithms that baton-pass locks~\cite{Andrews89} between threads instead of releasing the locks are said to be using barging prevention.
     1089Several tools can be used to solve concurrency challenges.
     1090Since 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}).
     1091In these paradigms, interaction among concurrent objects relies on message passing~\cite{Thoth,Harmony,V-Kernel} or other paradigms closely relate to networking concepts (channels~\cite{CSP,Go} for example).
     1092However, in languages that use routine calls as their core abstraction mechanism, these approaches force a clear distinction between concurrent and non-concurrent paradigms (\ie message passing versus routine calls).
     1093This distinction in turn means that, in order to be effective, programmers need to learn two sets of design patterns.
     1094While this distinction can be hidden away in library code, effective use of the library still has to take both paradigms into account.
     1095
     1096Approaches 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.
     1097At the lowest level, concurrent paradigms are implemented as atomic operations and locks.
     1098Many such mechanisms have been proposed, including semaphores~\cite{Dijkstra68b} and path expressions~\cite{Campbell74}.
     1099However, for productivity reasons it is desirable to have a higher-level construct be the core concurrency paradigm~\cite{Hochstein05}.
     1100
     1101An approach that is worth mentioning because it is gaining in popularity is transactional memory~\cite{Herlihy93}.
     1102While this approach is even pursued by system languages like \CC~\cite{Cpp-Transactions}, the performance and feature set is currently too restrictive to be the main concurrency paradigm for system languages, which is why it was rejected as the core paradigm for concurrency in \CFA.
     1103
     1104One of the most natural, elegant, and efficient mechanisms for synchronization and communication, especially for shared-memory systems, is the \emph{monitor}.
     1105Monitors were first proposed by Brinch Hansen~\cite{Hansen73} and later described and extended by C.A.R.~Hoare~\cite{Hoare74}.
     1106Many programming languages---\eg 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.
     1107In 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.
     1108For these reasons, this project proposes monitors as the core concurrency construct.
     1109
     1110
     1111\subsection{Basics}
     1112
     1113Non-determinism requires concurrent systems to offer support for mutual-exclusion and synchronization.
     1114Mutual-exclusion is the concept that only a fixed number of threads can access a critical section at any given time, where a critical section is a group of instructions on an associated portion of data that requires the restricted access.
     1115On the other hand, synchronization enforces relative ordering of execution and synchronization tools provide numerous mechanisms to establish timing relationships among threads.
     1116
     1117
     1118\subsubsection{Mutual-Exclusion}
     1119
     1120As mentioned above, mutual-exclusion is the guarantee that only a fix number of threads can enter a critical section at once.
     1121However, many solutions exist for mutual exclusion, which vary in terms of performance, flexibility and ease of use.
     1122Methods range from low-level locks, which are fast and flexible but require significant attention to be correct, to  higher-level concurrency techniques, which sacrifice some performance in order to improve ease of use.
     1123Ease of use comes by either guaranteeing some problems cannot occur (\eg being deadlock free) or by offering a more explicit coupling between data and corresponding critical section.
     1124For example, the \CC @std::atomic<T>@ offers an easy way to express mutual-exclusion on a restricted set of operations (\eg reading/writing large types atomically).
     1125Another challenge with low-level locks is composability.
     1126Locks have restricted composability because it takes careful organizing for multiple locks to be used while preventing deadlocks.
     1127Easing composability is another feature higher-level mutual-exclusion mechanisms often offer.
     1128
     1129
     1130\subsubsection{Synchronization}
     1131
     1132As with mutual-exclusion, low-level synchronization primitives often offer good performance and good flexibility at the cost of ease of use.
     1133Again, higher-level mechanisms often simplify usage by adding either better coupling between synchronization and data (\eg message passing) or offering a simpler solution to otherwise involved challenges.
     1134As mentioned above, synchronization can be expressed as guaranteeing that event \textit{X} always happens before \textit{Y}.
     1135Most of the time, synchronization happens within a critical section, where threads must acquire mutual-exclusion in a certain order.
     1136However, it may also be desirable to guarantee that event \textit{Z} does not occur between \textit{X} and \textit{Y}.
     1137Not satisfying this property is called \textbf{barging}.
     1138For example, where event \textit{X} tries to effect event \textit{Y} but another thread acquires the critical section and emits \textit{Z} before \textit{Y}.
     1139The classic example is the thread that finishes using a resource and unblocks a thread waiting to use the resource, but the unblocked thread must compete to acquire the resource.
     1140Preventing or detecting barging is an involved challenge with low-level locks, which can be made much easier by higher-level constructs.
     1141This challenge is often split into two different methods, barging avoidance and barging prevention.
     1142Algorithms that use flag variables to detect barging threads are said to be using barging avoidance, while algorithms that baton-pass locks~\cite{Andrews89} between threads instead of releasing the locks are said to be using barging prevention.
     1143
    7871144
    7881145% ======================================================================
     
    7911148% ======================================================================
    7921149% ======================================================================
    793 A \textbf{monitor} is a set of routines that ensure mutual-exclusion when accessing shared state. More precisely, a monitor is a programming technique that associates mutual-exclusion to routine scopes, as opposed to mutex locks, where mutual-exclusion is defined by lock/release calls independently of any scoping of the calling routine. This strong association eases readability and maintainability, at the cost of flexibility. Note that both monitors and mutex locks, require an abstract handle to identify them. This concept is generally associated with object-oriented languages like Java~\cite{Java} or \uC~\cite{uC++book} but does not strictly require OO semantics. The only requirement is the ability to declare a handle to a shared object and a set of routines that act on it:
    794 \begin{cfacode}
     1150A \textbf{monitor} is a set of routines that ensure mutual-exclusion when accessing shared state.
     1151More precisely, a monitor is a programming technique that associates mutual-exclusion to routine scopes, as opposed to mutex locks, where mutual-exclusion is defined by lock/release calls independently of any scoping of the calling routine.
     1152This strong association eases readability and maintainability, at the cost of flexibility.
     1153Note that both monitors and mutex locks, require an abstract handle to identify them.
     1154This concept is generally associated with object-oriented languages like Java~\cite{Java} or \uC~\cite{uC++book} but does not strictly require OO semantics.
     1155The only requirement is the ability to declare a handle to a shared object and a set of routines that act on it:
     1156\begin{cfa}
    7951157typedef /*some monitor type*/ monitor;
    7961158int f(monitor & m);
    7971159
    7981160int main() {
    799         monitor m;  //Handle m
    800         f(m);       //Routine using handle
    801 }
    802 \end{cfacode}
     1161        monitor m;  // Handle m
     1162        f(m);       // Routine using handle
     1163}
     1164\end{cfa}
    8031165
    8041166% ======================================================================
     
    8071169% ======================================================================
    8081170% ======================================================================
    809 The above monitor example displays some of the intrinsic characteristics. First, it is necessary to use pass-by-reference over pass-by-value for monitor routines. This semantics is important, because at their core, monitors are implicit mutual-exclusion objects (locks), and these objects cannot be copied. Therefore, monitors are non-copy-able objects (\code{dtype}).
    810 
    811 Another aspect to consider is when a monitor acquires its mutual exclusion. For example, a monitor may need to be passed through multiple helper routines that do not acquire the monitor mutual-exclusion on entry. Passthrough can occur for generic helper routines (\code{swap}, \code{sort}, etc.) or specific helper routines like the following to implement an atomic counter:
    812 
    813 \begin{cfacode}
     1171The above monitor example displays some of the intrinsic characteristics.
     1172First, it is necessary to use pass-by-reference over pass-by-value for monitor routines.
     1173This semantics is important, because at their core, monitors are implicit mutual-exclusion objects (locks), and these objects cannot be copied.
     1174Therefore, monitors are non-copy-able objects (@dtype@).
     1175
     1176Another aspect to consider is when a monitor acquires its mutual exclusion.
     1177For example, a monitor may need to be passed through multiple helper routines that do not acquire the monitor mutual-exclusion on entry.
     1178Passthrough can occur for generic helper routines (@swap@, @sort@, \etc) or specific helper routines like the following to implement an atomic counter:
     1179
     1180\begin{cfa}
    8141181monitor counter_t { /*...see section $\ref{data}$...*/ };
    8151182
    816 void ?{}(counter_t & nomutex this); //constructor
    817 size_t ++?(counter_t & mutex this); //increment
    818 
    819 //need for mutex is platform dependent
    820 void ?{}(size_t * this, counter_t & mutex cnt); //conversion
    821 \end{cfacode}
     1183void ?{}(counter_t & nomutex this); // constructor
     1184size_t ++?(counter_t & mutex this); // increment
     1185
     1186// need for mutex is platform dependent
     1187void ?{}(size_t * this, counter_t & mutex cnt); // conversion
     1188\end{cfa}
    8221189This counter is used as follows:
    8231190\begin{center}
    8241191\begin{tabular}{c @{\hskip 0.35in} c @{\hskip 0.35in} c}
    825 \begin{cfacode}
    826 //shared counter
     1192\begin{cfa}
     1193// shared counter
    8271194counter_t cnt1, cnt2;
    8281195
    829 //multiple threads access counter
     1196// multiple threads access counter
    8301197thread 1 : cnt1++; cnt2++;
    8311198thread 2 : cnt1++; cnt2++;
     
    8331200        ...
    8341201thread N : cnt1++; cnt2++;
    835 \end{cfacode}
     1202\end{cfa}
    8361203\end{tabular}
    8371204\end{center}
    838 Notice how the counter is used without any explicit synchronization and yet supports thread-safe semantics for both reading and writing, which is similar in usage to the \CC template \code{std::atomic}.
    839 
    840 Here, the constructor (\code{?\{\}}) uses the \code{nomutex} keyword to signify that it does not acquire the monitor mutual-exclusion when constructing. This semantics is because an object not yet con\-structed should never be shared and therefore does not require mutual exclusion. Furthermore, it allows the implementation greater freedom when it initializes the monitor locking. The prefix increment operator uses \code{mutex} to protect the incrementing process from race conditions. Finally, there is a conversion operator from \code{counter_t} to \code{size_t}. This conversion may or may not require the \code{mutex} keyword depending on whether or not reading a \code{size_t} is an atomic operation.
    841 
    842 For maximum usability, monitors use \textbf{multi-acq} semantics, which means a single thread can acquire the same monitor multiple times without deadlock. For example, listing \ref{fig:search} uses recursion and \textbf{multi-acq} to print values inside a binary tree.
     1205Notice how the counter is used without any explicit synchronization and yet supports thread-safe semantics for both reading and writing, which is similar in usage to the \CC template @std::atomic@.
     1206
     1207Here, the constructor (@?{}@) uses the @nomutex@ keyword to signify that it does not acquire the monitor mutual-exclusion when constructing.
     1208This semantics is because an object not yet constructed should never be shared and therefore does not require mutual exclusion.
     1209Furthermore, it allows the implementation greater freedom when it initializes the monitor locking.
     1210The prefix increment operator uses @mutex@ to protect the incrementing process from race conditions.
     1211Finally, there is a conversion operator from @counter_t@ to @size_t@.
     1212This conversion may or may not require the @mutex@ keyword depending on whether or not reading a @size_t@ is an atomic operation.
     1213
     1214For maximum usability, monitors use \textbf{multi-acq} semantics, which means a single thread can acquire the same monitor multiple times without deadlock.
     1215For example, listing \ref{fig:search} uses recursion and \textbf{multi-acq} to print values inside a binary tree.
    8431216\begin{figure}
    844 \begin{cfacode}[caption={Recursive printing algorithm using \textbf{multi-acq}.},label={fig:search}]
     1217\begin{cfa}[caption={Recursive printing algorithm using \textbf{multi-acq}.},label={fig:search}]
    8451218monitor printer { ... };
    8461219struct tree {
     
    8551228        print(p, t->right);
    8561229}
    857 \end{cfacode}
     1230\end{cfa}
    8581231\end{figure}
    8591232
    860 Having both \code{mutex} and \code{nomutex} keywords can be redundant, depending on the meaning of a routine having neither of these keywords. For example, it is reasonable that it should default to the safest option (\code{mutex}) when given a routine without qualifiers \code{void foo(counter_t & this)}, whereas assuming \code{nomutex} is unsafe and may cause subtle errors. On the other hand, \code{nomutex} is the ``normal'' parameter behaviour, it effectively states explicitly that ``this routine is not special''. Another alternative is making exactly one of these keywords mandatory, which provides the same semantics but without the ambiguity of supporting routines with neither keyword. Mandatory keywords would also have the added benefit of being self-documented but at the cost of extra typing. While there are several benefits to mandatory keywords, they do bring a few challenges. Mandatory keywords in \CFA would imply that the compiler must know without doubt whether or not a parameter is a monitor or not. Since \CFA relies heavily on traits as an abstraction mechanism, the distinction between a type that is a monitor and a type that looks like a monitor can become blurred. For this reason, \CFA only has the \code{mutex} keyword and uses no keyword to mean \code{nomutex}.
    861 
    862 The next semantic decision is to establish when \code{mutex} may be used as a type qualifier. Consider the following declarations:
    863 \begin{cfacode}
     1233Having both @mutex@ and @nomutex@ keywords can be redundant, depending on the meaning of a routine having neither of these keywords.
     1234For example, it is reasonable that it should default to the safest option (@mutex@) when given a routine without qualifiers @void foo(counter_t & this)@, whereas assuming @nomutex@ is unsafe and may cause subtle errors.
     1235On the other hand, @nomutex@ is the ``normal'' parameter behaviour, it effectively states explicitly that ``this routine is not special''.
     1236Another alternative is making exactly one of these keywords mandatory, which provides the same semantics but without the ambiguity of supporting routines with neither keyword.
     1237Mandatory keywords would also have the added benefit of being self-documented but at the cost of extra typing.
     1238While there are several benefits to mandatory keywords, they do bring a few challenges.
     1239Mandatory keywords in \CFA would imply that the compiler must know without doubt whether or not a parameter is a monitor or not.
     1240Since \CFA relies heavily on traits as an abstraction mechanism, the distinction between a type that is a monitor and a type that looks like a monitor can become blurred.
     1241For this reason, \CFA only has the @mutex@ keyword and uses no keyword to mean @nomutex@.
     1242
     1243The next semantic decision is to establish when @mutex@ may be used as a type qualifier.
     1244Consider the following declarations:
     1245\begin{cfa}
    8641246int f1(monitor & mutex m);
    8651247int f2(const monitor & mutex m);
     
    8671249int f4(monitor * mutex m []);
    8681250int f5(graph(monitor *) & mutex m);
    869 \end{cfacode}
    870 The problem is to identify which object(s) should be acquired. Furthermore, each object needs to be acquired only once. In the case of simple routines like \code{f1} and \code{f2} it is easy to identify an exhaustive list of objects to acquire on entry. Adding indirections (\code{f3}) still allows the compiler and programmer to identify which object is acquired. However, adding in arrays (\code{f4}) makes it much harder. Array lengths are not necessarily known in C, and even then, making sure objects are only acquired once becomes none-trivial. This problem can be extended to absurd limits like \code{f5}, which uses a graph of monitors. To make the issue tractable, this project imposes the requirement that a routine may only acquire one monitor per parameter and it must be the type of the parameter with at most one level of indirection (ignoring potential qualifiers). Also note that while routine \code{f3} can be supported, meaning that monitor \code{**m} is acquired, passing an array to this routine would be type-safe and yet result in undefined behaviour because only the first element of the array is acquired. However, this ambiguity is part of the C type-system with respects to arrays. For this reason, \code{mutex} is disallowed in the context where arrays may be passed:
    871 \begin{cfacode}
    872 int f1(monitor & mutex m);    //Okay : recommended case
    873 int f2(monitor * mutex m);    //Not Okay : Could be an array
    874 int f3(monitor mutex m []);  //Not Okay : Array of unknown length
    875 int f4(monitor ** mutex m);   //Not Okay : Could be an array
    876 int f5(monitor * mutex m []); //Not Okay : Array of unknown length
    877 \end{cfacode}
    878 Note that not all array functions are actually distinct in the type system. However, even if the code generation could tell the difference, the extra information is still not sufficient to extend meaningfully the monitor call semantic.
    879 
    880 Unlike object-oriented monitors, where calling a mutex member \emph{implicitly} acquires mutual-exclusion of the receiver object, \CFA uses an explicit mechanism to specify the object that acquires mutual-exclusion. A consequence of this approach is that it extends naturally to multi-monitor calls.
    881 \begin{cfacode}
     1251\end{cfa}
     1252The problem is to identify which object(s) should be acquired.
     1253Furthermore, each object needs to be acquired only once.
     1254In the case of simple routines like @f1@ and @f2@ it is easy to identify an exhaustive list of objects to acquire on entry.
     1255Adding indirections (@f3@) still allows the compiler and programmer to identify which object is acquired.
     1256However, adding in arrays (@f4@) makes it much harder.
     1257Array lengths are not necessarily known in C, and even then, making sure objects are only acquired once becomes none-trivial.
     1258This problem can be extended to absurd limits like @f5@, which uses a graph of monitors.
     1259To make the issue tractable, this project imposes the requirement that a routine may only acquire one monitor per parameter and it must be the type of the parameter with at most one level of indirection (ignoring potential qualifiers).
     1260Also note that while routine @f3@ can be supported, meaning that monitor @**m@ is acquired, passing an array to this routine would be type-safe and yet result in undefined behaviour because only the first element of the array is acquired.
     1261However, this ambiguity is part of the C type-system with respects to arrays.
     1262For this reason, @mutex@ is disallowed in the context where arrays may be passed:
     1263\begin{cfa}
     1264int f1(monitor & mutex m);    // Okay : recommended case
     1265int f2(monitor * mutex m);    // Not Okay : Could be an array
     1266int f3(monitor mutex m []);  // Not Okay : Array of unknown length
     1267int f4(monitor ** mutex m);   // Not Okay : Could be an array
     1268int f5(monitor * mutex m []); // Not Okay : Array of unknown length
     1269\end{cfa}
     1270Note that not all array functions are actually distinct in the type system.
     1271However, even if the code generation could tell the difference, the extra information is still not sufficient to extend meaningfully the monitor call semantic.
     1272
     1273Unlike object-oriented monitors, where calling a mutex member \emph{implicitly} acquires mutual-exclusion of the receiver object, \CFA uses an explicit mechanism to specify the object that acquires mutual-exclusion.
     1274A consequence of this approach is that it extends naturally to multi-monitor calls.
     1275\begin{cfa}
    8821276int f(MonitorA & mutex a, MonitorB & mutex b);
    8831277
     
    8851279MonitorB b;
    8861280f(a,b);
    887 \end{cfacode}
    888 While OO monitors could be extended with a mutex qualifier for multiple-monitor calls, no example of this feature could be found. The capability to acquire multiple locks before entering a critical section is called \emph{\textbf{bulk-acq}}. In practice, writing multi-locking routines that do not lead to deadlocks is tricky. Having language support for such a feature is therefore a significant asset for \CFA. In the case presented above, \CFA guarantees that the order of acquisition is consistent across calls to different routines using the same monitors as arguments. This consistent ordering means acquiring multiple monitors is safe from deadlock when using \textbf{bulk-acq}. However, users can still force the acquiring order. For example, notice which routines use \code{mutex}/\code{nomutex} and how this affects acquiring order:
    889 \begin{cfacode}
    890 void foo(A& mutex a, B& mutex b) { //acquire a & b
     1281\end{cfa}
     1282While OO monitors could be extended with a mutex qualifier for multiple-monitor calls, no example of this feature could be found.
     1283The capability to acquire multiple locks before entering a critical section is called \emph{\textbf{bulk-acq}}.
     1284In practice, writing multi-locking routines that do not lead to deadlocks is tricky.
     1285Having language support for such a feature is therefore a significant asset for \CFA.
     1286In the case presented above, \CFA guarantees that the order of acquisition is consistent across calls to different routines using the same monitors as arguments.
     1287This consistent ordering means acquiring multiple monitors is safe from deadlock when using \textbf{bulk-acq}.
     1288However, users can still force the acquiring order.
     1289For example, notice which routines use @mutex@/@nomutex@ and how this affects acquiring order:
     1290\begin{cfa}
     1291void foo(A& mutex a, B& mutex b) { // acquire a & b
    8911292        ...
    8921293}
    8931294
    894 void bar(A& mutex a, B& /*nomutex*/ b) { //acquire a
    895         ... foo(a, b); ... //acquire b
    896 }
    897 
    898 void baz(A& /*nomutex*/ a, B& mutex b) { //acquire b
    899         ... foo(a, b); ... //acquire a
    900 }
    901 \end{cfacode}
    902 The \textbf{multi-acq} 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.
    903 
    904 However, such use leads to lock acquiring order problems. 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 difference means that calling these routines concurrently may lead to deadlock and is therefore undefined behaviour. As shown~\cite{Lister77}, solving this problem requires:
     1295void bar(A& mutex a, B& /*nomutex*/ b) { // acquire a
     1296        ... foo(a, b); ... // acquire b
     1297}
     1298
     1299void baz(A& /*nomutex*/ a, B& mutex b) { // acquire b
     1300        ... foo(a, b); ... // acquire a
     1301}
     1302\end{cfa}
     1303The \textbf{multi-acq} monitor lock allows a monitor lock to be acquired by both @bar@ or @baz@ and acquired again in @foo@.
     1304In the calls to @bar@ and @baz@ the monitors are acquired in opposite order.
     1305
     1306However, such use leads to lock acquiring order problems.
     1307In the example above, the user uses implicit ordering in the case of function @foo@ but explicit ordering in the case of @bar@ and @baz@.
     1308This subtle difference means that calling these routines concurrently may lead to deadlock and is therefore undefined behaviour.
     1309As shown~\cite{Lister77}, solving this problem requires:
    9051310\begin{enumerate}
    9061311        \item Dynamically tracking the monitor-call order.
    9071312        \item Implement rollback semantics.
    9081313\end{enumerate}
    909 While the first requirement is already a significant constraint on the system, implementing a general rollback semantics in a C-like language is still prohibitively complex~\cite{Dice10}. In \CFA, users simply need to be careful when acquiring multiple monitors at the same time or only use \textbf{bulk-acq} of all the monitors. While \CFA provides only a partial solution, most systems provide no solution and the \CFA partial solution handles many useful cases.
     1314While the first requirement is already a significant constraint on the system, implementing a general rollback semantics in a C-like language is still prohibitively complex~\cite{Dice10}.
     1315In \CFA, users simply need to be careful when acquiring multiple monitors at the same time or only use \textbf{bulk-acq} of all the monitors.
     1316While \CFA provides only a partial solution, most systems provide no solution and the \CFA partial solution handles many useful cases.
    9101317
    9111318For example, \textbf{multi-acq} and \textbf{bulk-acq} can be used together in interesting ways:
    912 \begin{cfacode}
     1319\begin{cfa}
    9131320monitor bank { ... };
    9141321
     
    9191326        deposit( yourbank, me2you );
    9201327}
    921 \end{cfacode}
    922 This example shows a trivial solution to the bank-account transfer problem~\cite{BankTransfer}. Without \textbf{multi-acq} and \textbf{bulk-acq}, the solution to this problem is much more involved and requires careful engineering.
    923 
    924 \subsection{\code{mutex} statement} \label{mutex-stmt}
    925 
    926 The call semantics discussed above have one software engineering issue: only a routine can acquire the mutual-exclusion of a set of monitor. \CFA offers the \code{mutex} statement to work around the need for unnecessary names, avoiding a major software engineering problem~\cite{2FTwoHardThings}. Table \ref{lst:mutex-stmt} shows an example of the \code{mutex} statement, which introduces a new scope in which the mutual-exclusion of a set of monitor is acquired. Beyond naming, the \code{mutex} statement has no semantic difference from a routine call with \code{mutex} parameters.
     1328\end{cfa}
     1329This example shows a trivial solution to the bank-account transfer problem~\cite{BankTransfer}.
     1330Without \textbf{multi-acq} and \textbf{bulk-acq}, the solution to this problem is much more involved and requires careful engineering.
     1331
     1332
     1333\subsection{\protect\lstinline|mutex| statement} \label{mutex-stmt}
     1334
     1335The call semantics discussed above have one software engineering issue: only a routine can acquire the mutual-exclusion of a set of monitor. \CFA offers the @mutex@ statement to work around the need for unnecessary names, avoiding a major software engineering problem~\cite{2FTwoHardThings}.
     1336Table \ref{f:mutex-stmt} shows an example of the @mutex@ statement, which introduces a new scope in which the mutual-exclusion of a set of monitor is acquired.
     1337Beyond naming, the @mutex@ statement has no semantic difference from a routine call with @mutex@ parameters.
    9271338
    9281339\begin{table}
    9291340\begin{center}
    9301341\begin{tabular}{|c|c|}
    931 function call & \code{mutex} statement \\
     1342function call & @mutex@ statement \\
    9321343\hline
    933 \begin{cfacode}[tabsize=3]
     1344\begin{cfa}[tabsize=3]
    9341345monitor M {};
    9351346void foo( M & mutex m1, M & mutex m2 ) {
    936         //critical section
     1347        // critical section
    9371348}
    9381349
     
    9401351        foo( m1, m2 );
    9411352}
    942 \end{cfacode}&\begin{cfacode}[tabsize=3]
     1353\end{cfa}&\begin{cfa}[tabsize=3]
    9431354monitor M {};
    9441355void bar( M & m1, M & m2 ) {
    9451356        mutex(m1, m2) {
    946                 //critical section
     1357                // critical section
    9471358        }
    9481359}
    9491360
    9501361
    951 \end{cfacode}
     1362\end{cfa}
    9521363\end{tabular}
    9531364\end{center}
    954 \caption{Regular call semantics vs. \code{mutex} statement}
    955 \label{lst:mutex-stmt}
     1365\caption{Regular call semantics vs. \protect\lstinline|mutex| statement}
     1366\label{f:mutex-stmt}
    9561367\end{table}
    9571368
     
    9611372% ======================================================================
    9621373% ======================================================================
    963 Once the call semantics are established, the next step is to establish data semantics. Indeed, until now a monitor is used simply as a generic handle but in most cases monitors contain shared data. This data should be intrinsic to the monitor declaration to prevent any accidental use of data without its appropriate protection. For example, here is a complete version of the counter shown in section \ref{call}:
    964 \begin{cfacode}
     1374Once the call semantics are established, the next step is to establish data semantics.
     1375Indeed, until now a monitor is used simply as a generic handle but in most cases monitors contain shared data.
     1376This data should be intrinsic to the monitor declaration to prevent any accidental use of data without its appropriate protection.
     1377For example, here is a complete version of the counter shown in section \ref{call}:
     1378\begin{cfa}
    9651379monitor counter_t {
    9661380        int value;
     
    9751389}
    9761390
    977 //need for mutex is platform dependent here
     1391// need for mutex is platform dependent here
    9781392void ?{}(int * this, counter_t & mutex cnt) {
    9791393        *this = (int)cnt;
    9801394}
    981 \end{cfacode}
    982 
    983 Like threads and coroutines, monitors are defined in terms of traits with some additional language support in the form of the \code{monitor} keyword. The monitor trait is:
    984 \begin{cfacode}
     1395\end{cfa}
     1396
     1397Like threads and coroutines, monitors are defined in terms of traits with some additional language support in the form of the @monitor@ keyword.
     1398The monitor trait is:
     1399\begin{cfa}
    9851400trait is_monitor(dtype T) {
    9861401        monitor_desc * get_monitor( T & );
    9871402        void ^?{}( T & mutex );
    9881403};
    989 \end{cfacode}
    990 Note that the destructor of a monitor must be a \code{mutex} routine to prevent deallocation while a thread is accessing the monitor. As with any object, calls to a monitor, using \code{mutex} or otherwise, is undefined behaviour after the destructor has run.
     1404\end{cfa}
     1405Note that the destructor of a monitor must be a @mutex@ routine to prevent deallocation while a thread is accessing the monitor.
     1406As with any object, calls to a monitor, using @mutex@ or otherwise, is undefined behaviour after the destructor has run.
    9911407
    9921408% ======================================================================
     
    9951411% ======================================================================
    9961412% ======================================================================
    997 In addition to mutual exclusion, the monitors at the core of \CFA's concurrency can also be used to achieve synchronization. With monitors, this capability is generally achieved with internal or external scheduling as in~\cite{Hoare74}. With \textbf{scheduling} loosely defined as deciding which thread acquires the critical section next, \textbf{internal scheduling} means making the decision from inside the critical section (i.e., with access to the shared state), while \textbf{external scheduling} means making the decision when entering the critical section (i.e., without access to the shared state). Since internal scheduling within a single monitor is mostly a solved problem, this paper concentrates on extending internal scheduling to multiple monitors. Indeed, like the \textbf{bulk-acq} semantics, internal scheduling extends to multiple monitors in a way that is natural to the user but requires additional complexity on the implementation side.
     1413In addition to mutual exclusion, the monitors at the core of \CFA's concurrency can also be used to achieve synchronization.
     1414With monitors, this capability is generally achieved with internal or external scheduling as in~\cite{Hoare74}.
     1415With \textbf{scheduling} loosely defined as deciding which thread acquires the critical section next, \textbf{internal scheduling} means making the decision from inside the critical section (\ie with access to the shared state), while \textbf{external scheduling} means making the decision when entering the critical section (\ie without access to the shared state).
     1416Since internal scheduling within a single monitor is mostly a solved problem, this paper concentrates on extending internal scheduling to multiple monitors.
     1417Indeed, like the \textbf{bulk-acq} semantics, internal scheduling extends to multiple monitors in a way that is natural to the user but requires additional complexity on the implementation side.
    9981418
    9991419First, here is a simple example of internal scheduling:
    10001420
    1001 \begin{cfacode}
     1421\begin{cfa}
    10021422monitor A {
    10031423        condition e;
     
    10061426void foo(A& mutex a1, A& mutex a2) {
    10071427        ...
    1008         //Wait for cooperation from bar()
     1428        // Wait for cooperation from bar()
    10091429        wait(a1.e);
    10101430        ...
     
    10121432
    10131433void bar(A& mutex a1, A& mutex a2) {
    1014         //Provide cooperation for foo()
     1434        // Provide cooperation for foo()
    10151435        ...
    1016         //Unblock foo
     1436        // Unblock foo
    10171437        signal(a1.e);
    10181438}
    1019 \end{cfacode}
    1020 There are two details to note here. First, \code{signal} is a delayed operation; it only unblocks the waiting thread when it reaches the end of the critical section. This semantics is needed to respect mutual-exclusion, i.e., the signaller and signalled thread cannot be in the monitor simultaneously. The alternative is to return immediately after the call to \code{signal}, which is significantly more restrictive. Second, in \CFA, while it is common to store a \code{condition} as a field of the monitor, a \code{condition} variable can be stored/created independently of a monitor. Here routine \code{foo} waits for the \code{signal} from \code{bar} before making further progress, ensuring a basic ordering.
    1021 
    1022 An important aspect of the implementation is that \CFA does not allow barging, which means that once function \code{bar} releases the monitor, \code{foo} is guaranteed to be the next thread to acquire the monitor (unless some other thread waited on the same condition). This guarantee offers the benefit of not having to loop around waits to recheck that a condition is 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 and implementation of \CFA concurrency.
     1439\end{cfa}
     1440There are two details to note here.
     1441First, @signal@ is a delayed operation; it only unblocks the waiting thread when it reaches the end of the critical section.
     1442This semantics is needed to respect mutual-exclusion, \ie the signaller and signalled thread cannot be in the monitor simultaneously.
     1443The alternative is to return immediately after the call to @signal@, which is significantly more restrictive.
     1444Second, in \CFA, while it is common to store a @condition@ as a field of the monitor, a @condition@ variable can be stored/created independently of a monitor.
     1445Here routine @foo@ waits for the @signal@ from @bar@ before making further progress, ensuring a basic ordering.
     1446
     1447An important aspect of the implementation is that \CFA does not allow barging, which means that once function @bar@ releases the monitor, @foo@ is guaranteed to be the next thread to acquire the monitor (unless some other thread waited on the same condition).
     1448This guarantee offers the benefit of not having to loop around waits to recheck that a condition is met.
     1449The 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.
     1450Supporting barging prevention as well as extending internal scheduling to multiple monitors is the main source of complexity in the design and implementation of \CFA concurrency.
    10231451
    10241452% ======================================================================
     
    10271455% ======================================================================
    10281456% ======================================================================
    1029 It is easy to understand the problem of multi-monitor scheduling using a series of pseudo-code examples. Note that for simplicity in the following snippets of pseudo-code, waiting and signalling is done using an implicit condition variable, like Java built-in monitors. Indeed, \code{wait} statements always use the implicit condition variable as parameters and explicitly name the monitors (A and B) associated with the condition. Note that in \CFA, condition variables are tied to a \emph{group} of monitors on first use (called branding), which means that using internal scheduling with distinct sets of monitors requires one condition variable per set of monitors. The example below shows the simple case of having two threads (one for each column) and a single monitor A.
     1457It is easy to understand the problem of multi-monitor scheduling using a series of pseudo-code examples.
     1458Note that for simplicity in the following snippets of pseudo-code, waiting and signalling is done using an implicit condition variable, like Java built-in monitors.
     1459Indeed, @wait@ statements always use the implicit condition variable as parameters and explicitly name the monitors (A and B) associated with the condition.
     1460Note that in \CFA, condition variables are tied to a \emph{group} of monitors on first use (called branding), which means that using internal scheduling with distinct sets of monitors requires one condition variable per set of monitors.
     1461The example below shows the simple case of having two threads (one for each column) and a single monitor A.
    10301462
    10311463\begin{multicols}{2}
    10321464thread 1
    1033 \begin{pseudo}
     1465\begin{cfa}
    10341466acquire A
    10351467        wait A
    10361468release A
    1037 \end{pseudo}
     1469\end{cfa}
    10381470
    10391471\columnbreak
    10401472
    10411473thread 2
    1042 \begin{pseudo}
     1474\begin{cfa}
    10431475acquire A
    10441476        signal A
    10451477release A
    1046 \end{pseudo}
     1478\end{cfa}
    10471479\end{multicols}
    1048 One thread acquires before waiting (atomically blocking and releasing A) and the other acquires before signalling. It is important to note here that both \code{wait} and \code{signal} must be called with the proper monitor(s) already acquired. This semantic is a logical requirement for barging prevention.
     1480One thread acquires before waiting (atomically blocking and releasing A) and the other acquires before signalling.
     1481It is important to note here that both @wait@ and @signal@ must be called with the proper monitor(s) already acquired.
     1482This semantic is a logical requirement for barging prevention.
    10491483
    10501484A direct extension of the previous example is a \textbf{bulk-acq} version:
    10511485\begin{multicols}{2}
    1052 \begin{pseudo}
     1486\begin{cfa}
    10531487acquire A & B
    10541488        wait A & B
    10551489release A & B
    1056 \end{pseudo}
     1490\end{cfa}
    10571491\columnbreak
    1058 \begin{pseudo}
     1492\begin{cfa}
    10591493acquire A & B
    10601494        signal A & B
    10611495release A & B
    1062 \end{pseudo}
     1496\end{cfa}
    10631497\end{multicols}
    1064 \noindent This version uses \textbf{bulk-acq} (denoted using the {\sf\&} 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 a group of monitors. On the implementation side, handling multiple monitors does add a degree of complexity as the next few examples demonstrate.
    1065 
    1066 While deadlock issues can occur when nesting monitors, these issues are only a symptom of the fact that locks, and by extension monitors, are not perfectly composable. For monitors, a well-known deadlock problem is the Nested Monitor Problem~\cite{Lister77}, which occurs when a \code{wait} is made by a thread that holds more than one monitor. For example, the following pseudo-code runs into the nested-monitor problem:
     1498\noindent This version uses \textbf{bulk-acq} (denoted using the {\sf\&} symbol), but the presence of multiple monitors does not add a particularly new meaning.
     1499Synchronization happens between the two threads in exactly the same way and order.
     1500The only difference is that mutual exclusion covers a group of monitors.
     1501On the implementation side, handling multiple monitors does add a degree of complexity as the next few examples demonstrate.
     1502
     1503While deadlock issues can occur when nesting monitors, these issues are only a symptom of the fact that locks, and by extension monitors, are not perfectly composable.
     1504For monitors, a well-known deadlock problem is the Nested Monitor Problem~\cite{Lister77}, which occurs when a @wait@ is made by a thread that holds more than one monitor.
     1505For example, the following cfa-code runs into the nested-monitor problem:
    10671506\begin{multicols}{2}
    1068 \begin{pseudo}
     1507\begin{cfa}
    10691508acquire A
    10701509        acquire B
     
    10721511        release B
    10731512release A
    1074 \end{pseudo}
     1513\end{cfa}
    10751514
    10761515\columnbreak
    10771516
    1078 \begin{pseudo}
     1517\begin{cfa}
    10791518acquire A
    10801519        acquire B
     
    10821521        release B
    10831522release A
    1084 \end{pseudo}
     1523\end{cfa}
    10851524\end{multicols}
    1086 \noindent The \code{wait} only releases monitor \code{B} so the signalling thread cannot acquire monitor \code{A} to get to the \code{signal}. Attempting release of all acquired monitors at the \code{wait} introduces a different set of problems, such as releasing monitor \code{C}, which has nothing to do with the \code{signal}.
    1087 
    1088 However, for monitors as for locks, it is possible to write a program using nesting without encountering any problems if nesting is done correctly. For example, the next pseudo-code snippet acquires monitors {\sf A} then {\sf B} before waiting, while only acquiring {\sf B} when signalling, effectively avoiding the Nested Monitor Problem~\cite{Lister77}.
     1525\noindent The @wait@ only releases monitor @B@ so the signalling thread cannot acquire monitor @A@ to get to the @signal@.
     1526Attempting release of all acquired monitors at the @wait@ introduces a different set of problems, such as releasing monitor @C@, which has nothing to do with the @signal@.
     1527
     1528However, for monitors as for locks, it is possible to write a program using nesting without encountering any problems if nesting is done correctly.
     1529For example, the next cfa-code snippet acquires monitors {\sf A} then {\sf B} before waiting, while only acquiring {\sf B} when signalling, effectively avoiding the Nested Monitor Problem~\cite{Lister77}.
    10891530
    10901531\begin{multicols}{2}
    1091 \begin{pseudo}
     1532\begin{cfa}
    10921533acquire A
    10931534        acquire B
     
    10951536        release B
    10961537release A
    1097 \end{pseudo}
     1538\end{cfa}
    10981539
    10991540\columnbreak
    11001541
    1101 \begin{pseudo}
     1542\begin{cfa}
    11021543
    11031544acquire B
     
    11051546release B
    11061547
    1107 \end{pseudo}
     1548\end{cfa}
    11081549\end{multicols}
    11091550
     
    11161557% ======================================================================
    11171558
    1118 A larger example is presented to show complex issues for \textbf{bulk-acq} and its implementation options are analyzed. Listing \ref{lst:int-bulk-pseudo} shows an example where \textbf{bulk-acq} adds a significant layer of complexity to the internal signalling semantics, and listing \ref{lst:int-bulk-cfa} shows the corresponding \CFA code to implement the pseudo-code in listing \ref{lst:int-bulk-pseudo}. For the purpose of translating the given pseudo-code into \CFA-code, any method of introducing a monitor is acceptable, e.g., \code{mutex} parameters, global variables, pointer parameters, or using locals with the \code{mutex} statement.
    1119 
    1120 \begin{figure}[!t]
     1559A larger example is presented to show complex issues for \textbf{bulk-acq} and its implementation options are analyzed.
     1560Figure~\ref{f:int-bulk-cfa} shows an example where \textbf{bulk-acq} adds a significant layer of complexity to the internal signalling semantics, and listing \ref{f:int-bulk-cfa} shows the corresponding \CFA code to implement the cfa-code in listing \ref{f:int-bulk-cfa}.
     1561For the purpose of translating the given cfa-code into \CFA-code, any method of introducing a monitor is acceptable, \eg @mutex@ parameters, global variables, pointer parameters, or using locals with the @mutex@ statement.
     1562
     1563\begin{figure}
    11211564\begin{multicols}{2}
    11221565Waiting thread
    1123 \begin{pseudo}[numbers=left]
     1566\begin{cfa}[numbers=left]
    11241567acquire A
    1125         //Code Section 1
     1568        // Code Section 1
    11261569        acquire A & B
    1127                 //Code Section 2
     1570                // Code Section 2
    11281571                wait A & B
    1129                 //Code Section 3
     1572                // Code Section 3
    11301573        release A & B
    1131         //Code Section 4
     1574        // Code Section 4
    11321575release A
    1133 \end{pseudo}
     1576\end{cfa}
    11341577\columnbreak
    11351578Signalling thread
    1136 \begin{pseudo}[numbers=left, firstnumber=10,escapechar=|]
     1579\begin{cfa}[numbers=left, firstnumber=10,escapechar=|]
    11371580acquire A
    1138         //Code Section 5
     1581        // Code Section 5
    11391582        acquire A & B
    1140                 //Code Section 6
     1583                // Code Section 6
    11411584                |\label{line:signal1}|signal A & B
    1142                 //Code Section 7
     1585                // Code Section 7
    11431586        |\label{line:releaseFirst}|release A & B
    1144         //Code Section 8
     1587        // Code Section 8
    11451588|\label{line:lastRelease}|release A
    1146 \end{pseudo}
     1589\end{cfa}
    11471590\end{multicols}
    1148 \begin{cfacode}[caption={Internal scheduling with \textbf{bulk-acq}},label={lst:int-bulk-pseudo}]
    1149 \end{cfacode}
     1591\begin{cfa}[caption={Internal scheduling with \textbf{bulk-acq}},label={f:int-bulk-cfa}]
     1592\end{cfa}
    11501593\begin{center}
    1151 \begin{cfacode}[xleftmargin=.4\textwidth]
     1594\begin{cfa}[xleftmargin=.4\textwidth]
    11521595monitor A a;
    11531596monitor B b;
    11541597condition c;
    1155 \end{cfacode}
     1598\end{cfa}
    11561599\end{center}
    11571600\begin{multicols}{2}
    11581601Waiting thread
    1159 \begin{cfacode}
     1602\begin{cfa}
    11601603mutex(a) {
    1161         //Code Section 1
     1604        // Code Section 1
    11621605        mutex(a, b) {
    1163                 //Code Section 2
     1606                // Code Section 2
    11641607                wait(c);
    1165                 //Code Section 3
     1608                // Code Section 3
    11661609        }
    1167         //Code Section 4
    1168 }
    1169 \end{cfacode}
     1610        // Code Section 4
     1611}
     1612\end{cfa}
    11701613\columnbreak
    11711614Signalling thread
    1172 \begin{cfacode}
     1615\begin{cfa}
    11731616mutex(a) {
    1174         //Code Section 5
     1617        // Code Section 5
    11751618        mutex(a, b) {
    1176                 //Code Section 6
     1619                // Code Section 6
    11771620                signal(c);
    1178                 //Code Section 7
     1621                // Code Section 7
    11791622        }
    1180         //Code Section 8
    1181 }
    1182 \end{cfacode}
     1623        // Code Section 8
     1624}
     1625\end{cfa}
    11831626\end{multicols}
    1184 \begin{cfacode}[caption={Equivalent \CFA code for listing \ref{lst:int-bulk-pseudo}},label={lst:int-bulk-cfa}]
    1185 \end{cfacode}
     1627\begin{cfa}[caption={Equivalent \CFA code for listing \ref{f:int-bulk-cfa}},label={f:int-bulk-cfa}]
     1628\end{cfa}
    11861629\begin{multicols}{2}
    11871630Waiter
    1188 \begin{pseudo}[numbers=left]
     1631\begin{cfa}[numbers=left]
    11891632acquire A
    11901633        acquire A & B
     
    11921635        release A & B
    11931636release A
    1194 \end{pseudo}
     1637\end{cfa}
    11951638
    11961639\columnbreak
    11971640
    11981641Signaller
    1199 \begin{pseudo}[numbers=left, firstnumber=6,escapechar=|]
     1642\begin{cfa}[numbers=left, firstnumber=6,escapechar=|]
    12001643acquire A
    12011644        acquire A & B
    12021645                signal A & B
    12031646        release A & B
    1204         |\label{line:secret}|//Secretly keep B here
     1647        |\label{line:secret}|// Secretly keep B here
    12051648release A
    1206 //Wakeup waiter and transfer A & B
    1207 \end{pseudo}
     1649// Wakeup waiter and transfer A & B
     1650\end{cfa}
    12081651\end{multicols}
    1209 \begin{cfacode}[caption={Listing \ref{lst:int-bulk-pseudo}, with delayed signalling comments},label={lst:int-secret}]
    1210 \end{cfacode}
     1652\begin{cfa}[caption={Figure~\ref{f:int-bulk-cfa}, with delayed signalling comments},label={f:int-secret}]
     1653\end{cfa}
    12111654\end{figure}
    12121655
    1213 The complexity begins at code sections 4 and 8 in listing \ref{lst:int-bulk-pseudo}, which are where the existing semantics of internal scheduling needs to be extended for multiple monitors. The root of the problem is that \textbf{bulk-acq} is used in a context where one of the monitors is already acquired, which 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 \code{A & B}'' (listing \ref{lst:int-bulk-pseudo} line \ref{line:releaseFirst}), it must actually transfer ownership of monitor \code{B} to the waiting thread. This ownership transfer is required in order to prevent barging into \code{B} by another thread, since both the signalling and signalled threads still need monitor \code{A}. There are three options:
     1656The complexity begins at code sections 4 and 8 in listing \ref{f:int-bulk-cfa}, which are where the existing semantics of internal scheduling needs to be extended for multiple monitors.
     1657The root of the problem is that \textbf{bulk-acq} is used in a context where one of the monitors is already acquired, which is why it is important to define the behaviour of the previous cfa-code.
     1658When the signaller thread reaches the location where it should ``release @A & B@'' (listing \ref{f:int-bulk-cfa} line \ref{line:releaseFirst}), it must actually transfer ownership of monitor @B@ to the waiting thread.
     1659This ownership transfer is required in order to prevent barging into @B@ by another thread, since both the signalling and signalled threads still need monitor @A@.
     1660There are three options:
    12141661
    12151662\subsubsection{Delaying Signals}
    1216 The obvious solution to 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 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 multiple objects to a single group of objects, effectively making the existing single-monitor semantic viable by simply changing monitors to monitor groups. This solution releases the monitors once every monitor in a group can be released. However, since some monitors are never released (e.g., the monitor of a thread), this interpretation means a group might never be released. A more interesting interpretation is to transfer the group until all its monitors are released, which means the group is not passed further and a thread can retain its locks.
    1217 
    1218 However, listing \ref{lst:int-secret} shows this solution can become much more complicated depending on what is executed while secretly holding B at line \ref{line:secret}, while avoiding the need to transfer ownership of a subset of the condition monitors. Listing \ref{lst:dependency} shows a slightly different example where a third thread is waiting on monitor \code{A}, using a different condition variable. Because the third thread is signalled when secretly holding \code{B}, the goal  becomes unreachable. Depending on the order of signals (listing \ref{lst:dependency} line \ref{line:signal-ab} and \ref{line:signal-a}) two cases can happen:
    1219 
    1220 \paragraph{Case 1: thread $\alpha$ goes first.} In this case, the problem is that monitor \code{A} needs to be passed to thread $\beta$ when thread $\alpha$ is done with it.
    1221 \paragraph{Case 2: thread $\beta$ goes first.} In this case, the problem is that monitor \code{B} needs to be retained and passed to thread $\alpha$ along with monitor \code{A}, which can be done directly or possibly using thread $\beta$ as an intermediate.
     1663The obvious solution to the problem of multi-monitor scheduling is to keep ownership of all locks until the last lock is ready to be transferred.
     1664It can be argued that that moment is when the last lock is no longer needed, because this semantics fits most closely to the behaviour of single-monitor scheduling.
     1665This solution has the main benefit of transferring ownership of groups of monitors, which simplifies the semantics from multiple objects to a single group of objects, effectively making the existing single-monitor semantic viable by simply changing monitors to monitor groups.
     1666This solution releases the monitors once every monitor in a group can be released.
     1667However, since some monitors are never released (\eg the monitor of a thread), this interpretation means a group might never be released.
     1668A more interesting interpretation is to transfer the group until all its monitors are released, which means the group is not passed further and a thread can retain its locks.
     1669
     1670However, listing \ref{f:int-secret} shows this solution can become much more complicated depending on what is executed while secretly holding B at line \ref{line:secret}, while avoiding the need to transfer ownership of a subset of the condition monitors.
     1671Figure~\ref{f:dependency} shows a slightly different example where a third thread is waiting on monitor @A@, using a different condition variable.
     1672Because the third thread is signalled when secretly holding @B@, the goal  becomes unreachable.
     1673Depending on the order of signals (listing \ref{f:dependency} line \ref{line:signal-ab} and \ref{line:signal-a}) two cases can happen:
     1674
     1675\paragraph{Case 1: thread $\alpha$ goes first.} In this case, the problem is that monitor @A@ needs to be passed to thread $\beta$ when thread $\alpha$ is done with it.
     1676\paragraph{Case 2: thread $\beta$ goes first.} In this case, the problem is that monitor @B@ needs to be retained and passed to thread $\alpha$ along with monitor @A@, which can be done directly or possibly using thread $\beta$ as an intermediate.
    12221677\\
    12231678
    1224 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 \ref{line:signal-a} before line \ref{line:signal-ab} and get the reverse effect for listing \ref{lst:dependency}.
     1679Note that ordering is not determined by a race condition but by whether signalled threads are enqueued in FIFO or FILO order.
     1680However, regardless of the answer, users can move line \ref{line:signal-a} before line \ref{line:signal-ab} and get the reverse effect for listing \ref{f:dependency}.
    12251681
    12261682In both cases, 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 knowing when to release a group becomes complex and inefficient (see next section) and therefore effectively precludes this approach.
     
    12321688\begin{multicols}{3}
    12331689Thread $\alpha$
    1234 \begin{pseudo}[numbers=left, firstnumber=1]
     1690\begin{cfa}[numbers=left, firstnumber=1]
    12351691acquire A
    12361692        acquire A & B
     
    12381694        release A & B
    12391695release A
    1240 \end{pseudo}
     1696\end{cfa}
    12411697\columnbreak
    12421698Thread $\gamma$
    1243 \begin{pseudo}[numbers=left, firstnumber=6, escapechar=|]
     1699\begin{cfa}[numbers=left, firstnumber=6, escapechar=|]
    12441700acquire A
    12451701        acquire A & B
     
    12481704        |\label{line:signal-a}|signal A
    12491705|\label{line:release-a}|release A
    1250 \end{pseudo}
     1706\end{cfa}
    12511707\columnbreak
    12521708Thread $\beta$
    1253 \begin{pseudo}[numbers=left, firstnumber=12, escapechar=|]
     1709\begin{cfa}[numbers=left, firstnumber=12, escapechar=|]
    12541710acquire A
    12551711        wait A
    12561712|\label{line:release-aa}|release A
    1257 \end{pseudo}
     1713\end{cfa}
    12581714\end{multicols}
    1259 \begin{cfacode}[caption={Pseudo-code for the three thread example.},label={lst:dependency}]
    1260 \end{cfacode}
     1715\begin{cfa}[caption={Pseudo-code for the three thread example.},label={f:dependency}]
     1716\end{cfa}
    12611717\begin{center}
    12621718\input{dependency}
    12631719\end{center}
    1264 \caption{Dependency graph of the statements in listing \ref{lst:dependency}}
     1720\caption{Dependency graph of the statements in listing \ref{f:dependency}}
    12651721\label{fig:dependency}
    12661722\end{figure}
    12671723
    1268 In listing \ref{lst:int-bulk-pseudo}, there is a solution that satisfies both barging prevention and mutual exclusion. If ownership of both monitors is transferred to the waiter when the signaller releases \code{A & B} and then the waiter transfers back ownership of \code{A} back to the signaller when it releases it, then the problem is solved (\code{B} is no longer in use at this point). Dynamically finding the correct order is therefore the second possible solution. The problem is effectively resolving a dependency graph of ownership requirements. Here even the simplest of code snippets requires two transfers and has a super-linear complexity. This complexity can be seen in listing \ref{lst:explosion}, which is just a direct extension to three monitors, requires at least three ownership transfer and has multiple solutions. Furthermore, the presence of multiple solutions for ownership transfer can cause deadlock problems if a specific solution is not consistently picked; In the same way that multiple lock acquiring order can cause deadlocks.
     1724In listing \ref{f:int-bulk-cfa}, there is a solution that satisfies both barging prevention and mutual exclusion.
     1725If ownership of both monitors is transferred to the waiter when the signaller releases @A & B@ and then the waiter transfers back ownership of @A@ back to the signaller when it releases it, then the problem is solved (@B@ is no longer in use at this point).
     1726Dynamically finding the correct order is therefore the second possible solution.
     1727The problem is effectively resolving a dependency graph of ownership requirements.
     1728Here even the simplest of code snippets requires two transfers and has a super-linear complexity.
     1729This complexity can be seen in listing \ref{f:explosion}, which is just a direct extension to three monitors, requires at least three ownership transfer and has multiple solutions.
     1730Furthermore, the presence of multiple solutions for ownership transfer can cause deadlock problems if a specific solution is not consistently picked; In the same way that multiple lock acquiring order can cause deadlocks.
    12691731\begin{figure}
    12701732\begin{multicols}{2}
    1271 \begin{pseudo}
     1733\begin{cfa}
    12721734acquire A
    12731735        acquire B
     
    12771739        release B
    12781740release A
    1279 \end{pseudo}
     1741\end{cfa}
    12801742
    12811743\columnbreak
    12821744
    1283 \begin{pseudo}
     1745\begin{cfa}
    12841746acquire A
    12851747        acquire B
     
    12891751        release B
    12901752release A
    1291 \end{pseudo}
     1753\end{cfa}
    12921754\end{multicols}
    1293 \begin{cfacode}[caption={Extension to three monitors of listing \ref{lst:int-bulk-pseudo}},label={lst:explosion}]
    1294 \end{cfacode}
     1755\begin{cfa}[caption={Extension to three monitors of listing \ref{f:int-bulk-cfa}},label={f:explosion}]
     1756\end{cfa}
    12951757\end{figure}
    12961758
    1297 Given the three threads example in listing \ref{lst:dependency}, figure \ref{fig:dependency} shows the corresponding dependency graph that results, where every node is a statement of one of the three threads, and the arrows the dependency of that statement (e.g., $\alpha1$ must happen before $\alpha2$). The extra challenge is that this dependency graph is effectively post-mortem, but the runtime system needs to be able to build and solve these graphs as the dependencies unfold. Resolving dependency graphs being a complex and expensive endeavour, this solution is not the preferred one.
     1759Given the three threads example in listing \ref{f:dependency}, figure \ref{fig:dependency} shows the corresponding dependency graph that results, where every node is a statement of one of the three threads, and the arrows the dependency of that statement (\eg $\alpha1$ must happen before $\alpha2$).
     1760The extra challenge is that this dependency graph is effectively post-mortem, but the runtime system needs to be able to build and solve these graphs as the dependencies unfold.
     1761Resolving dependency graphs being a complex and expensive endeavour, this solution is not the preferred one.
    12981762
    12991763\subsubsection{Partial Signalling} \label{partial-sig}
    1300 Finally, the solution that is chosen for \CFA is to use partial signalling. Again using listing \ref{lst:int-bulk-pseudo}, the partial signalling solution transfers ownership of monitor \code{B} at lines \ref{line:signal1} to the waiter but does not wake the waiting thread since it is still using monitor \code{A}. Only when it reaches line \ref{line:lastRelease} does it actually wake up 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 released and conditionally waking threads if all conditions are met. This solution has a much simpler implementation than a dependency graph solving algorithms, which is why it was chosen. Furthermore, after being fully implemented, this solution does not appear to have any significant downsides.
    1301 
    1302 Using partial signalling, listing \ref{lst:dependency} can be solved easily:
     1764Finally, the solution that is chosen for \CFA is to use partial signalling.
     1765Again using listing \ref{f:int-bulk-cfa}, the partial signalling solution transfers ownership of monitor @B@ at lines \ref{line:signal1} to the waiter but does not wake the waiting thread since it is still using monitor @A@.
     1766Only when it reaches line \ref{line:lastRelease} does it actually wake up the waiting thread.
     1767This solution has the benefit that complexity is encapsulated into only two actions: passing monitors to the next owner when they should be released and conditionally waking threads if all conditions are met.
     1768This solution has a much simpler implementation than a dependency graph solving algorithms, which is why it was chosen.
     1769Furthermore, after being fully implemented, this solution does not appear to have any significant downsides.
     1770
     1771Using partial signalling, listing \ref{f:dependency} can be solved easily:
    13031772\begin{itemize}
    1304         \item When thread $\gamma$ reaches line \ref{line:release-ab} it transfers monitor \code{B} to thread $\alpha$ and continues to hold monitor \code{A}.
    1305         \item When thread $\gamma$ reaches line \ref{line:release-a}  it transfers monitor \code{A} to thread $\beta$  and wakes it up.
    1306         \item When thread $\beta$  reaches line \ref{line:release-aa} it transfers monitor \code{A} to thread $\alpha$ and wakes it up.
     1773        \item When thread $\gamma$ reaches line \ref{line:release-ab} it transfers monitor @B@ to thread $\alpha$ and continues to hold monitor @A@.
     1774        \item When thread $\gamma$ reaches line \ref{line:release-a}  it transfers monitor @A@ to thread $\beta$  and wakes it up.
     1775        \item When thread $\beta$  reaches line \ref{line:release-aa} it transfers monitor @A@ to thread $\alpha$ and wakes it up.
    13071776\end{itemize}
    13081777
     
    13141783\begin{table}
    13151784\begin{tabular}{|c|c|}
    1316 \code{signal} & \code{signal_block} \\
     1785@signal@ & @signal_block@ \\
    13171786\hline
    1318 \begin{cfacode}[tabsize=3]
    1319 monitor DatingService
    1320 {
    1321         //compatibility codes
     1787\begin{cfa}[tabsize=3]
     1788monitor DatingService {
     1789        // compatibility codes
    13221790        enum{ CCodes = 20 };
    13231791
     
    13301798condition exchange;
    13311799
    1332 int girl(int phoneNo, int ccode)
    1333 {
    1334         //no compatible boy ?
    1335         if(empty(boys[ccode]))
    1336         {
    1337                 //wait for boy
    1338                 wait(girls[ccode]);
    1339 
    1340                 //make phone number available
    1341                 girlPhoneNo = phoneNo;
    1342 
    1343                 //wake boy from chair
    1344                 signal(exchange);
    1345         }
    1346         else
    1347         {
    1348                 //make phone number available
    1349                 girlPhoneNo = phoneNo;
    1350 
    1351                 //wake boy
    1352                 signal(boys[ccode]);
    1353 
    1354                 //sit in chair
    1355                 wait(exchange);
     1800int girl(int phoneNo, int cfa) {
     1801        // no compatible boy ?
     1802        if(empty(boys[cfa])) {
     1803                wait(girls[cfa]);               // wait for boy
     1804                girlPhoneNo = phoneNo;          // make phone number available
     1805                signal(exchange);               // wake boy from chair
     1806        } else {
     1807                girlPhoneNo = phoneNo;          // make phone number available
     1808                signal(boys[cfa]);              // wake boy
     1809                wait(exchange);         // sit in chair
    13561810        }
    13571811        return boyPhoneNo;
    13581812}
    1359 
    1360 int boy(int phoneNo, int ccode)
    1361 {
    1362         //same as above
    1363         //with boy/girl interchanged
    1364 }
    1365 \end{cfacode}&\begin{cfacode}[tabsize=3]
    1366 monitor DatingService
    1367 {
    1368         //compatibility codes
    1369         enum{ CCodes = 20 };
     1813int boy(int phoneNo, int cfa) {
     1814        // same as above
     1815        // with boy/girl interchanged
     1816}
     1817\end{cfa}&\begin{cfa}[tabsize=3]
     1818monitor DatingService {
     1819
     1820        enum{ CCodes = 20 };    // compatibility codes
    13701821
    13711822        int girlPhoneNo;
     
    13751826condition girls[CCodes];
    13761827condition boys [CCodes];
    1377 //exchange is not needed
    1378 
    1379 int girl(int phoneNo, int ccode)
    1380 {
    1381         //no compatible boy ?
    1382         if(empty(boys[ccode]))
    1383         {
    1384                 //wait for boy
    1385                 wait(girls[ccode]);
    1386 
    1387                 //make phone number available
    1388                 girlPhoneNo = phoneNo;
    1389 
    1390                 //wake boy from chair
    1391                 signal(exchange);
    1392         }
    1393         else
    1394         {
    1395                 //make phone number available
    1396                 girlPhoneNo = phoneNo;
    1397 
    1398                 //wake boy
    1399                 signal_block(boys[ccode]);
    1400 
    1401                 //second handshake unnecessary
     1828// exchange is not needed
     1829
     1830int girl(int phoneNo, int cfa) {
     1831        // no compatible boy ?
     1832        if(empty(boys[cfa])) {
     1833                wait(girls[cfa]);               // wait for boy
     1834                girlPhoneNo = phoneNo;          // make phone number available
     1835                signal(exchange);               // wake boy from chair
     1836        } else {
     1837                girlPhoneNo = phoneNo;          // make phone number available
     1838                signal_block(boys[cfa]);                // wake boy
     1839
     1840                // second handshake unnecessary
    14021841
    14031842        }
     
    14051844}
    14061845
    1407 int boy(int phoneNo, int ccode)
    1408 {
    1409         //same as above
    1410         //with boy/girl interchanged
    1411 }
    1412 \end{cfacode}
     1846int boy(int phoneNo, int cfa) {
     1847        // same as above
     1848        // with boy/girl interchanged
     1849}
     1850\end{cfa}
    14131851\end{tabular}
    1414 \caption{Dating service example using \code{signal} and \code{signal_block}. }
     1852\caption{Dating service example using \protect\lstinline|signal| and \protect\lstinline|signal_block|. }
    14151853\label{tbl:datingservice}
    14161854\end{table}
    1417 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.
    1418 
    1419 The example in table \ref{tbl:datingservice} highlights the difference in behaviour. As mentioned, \code{signal} only transfers ownership once the current critical section exits; this behaviour requires additional synchronization when a two-way handshake is needed. To avoid this explicit synchronization, the \code{condition} type offers the \code{signal_block} routine, which handles the two-way handshake as shown in the example. This feature removes the need for a second condition variables and simplifies programming. Like every other monitor semantic, \code{signal_block} uses barging prevention, which means mutual-exclusion is baton-passed both on the front end and the back end of the call to \code{signal_block}, meaning no other thread can acquire the monitor either before or after the call.
     1855An important note is that, until now, signalling a monitor was a delayed operation.
     1856The ownership of the monitor is transferred only when the monitor would have otherwise been released, not at the point of the @signal@ statement.
     1857However, 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 @signal_block@ routine.
     1858
     1859The example in table \ref{tbl:datingservice} highlights the difference in behaviour.
     1860As mentioned, @signal@ only transfers ownership once the current critical section exits; this behaviour requires additional synchronization when a two-way handshake is needed.
     1861To avoid this explicit synchronization, the @condition@ type offers the @signal_block@ routine, which handles the two-way handshake as shown in the example.
     1862This feature removes the need for a second condition variables and simplifies programming.
     1863Like every other monitor semantic, @signal_block@ uses barging prevention, which means mutual-exclusion is baton-passed both on the front end and the back end of the call to @signal_block@, meaning no other thread can acquire the monitor either before or after the call.
    14201864
    14211865% ======================================================================
     
    14291873Internal Scheduling & External Scheduling & Go\\
    14301874\hline
    1431 \begin{ucppcode}[tabsize=3]
     1875\begin{uC++}[tabsize=3]
    14321876_Monitor Semaphore {
    14331877        condition c;
     
    14441888        }
    14451889}
    1446 \end{ucppcode}&\begin{ucppcode}[tabsize=3]
     1890\end{uC++}&\begin{uC++}[tabsize=3]
    14471891_Monitor Semaphore {
    14481892
     
    14591903        }
    14601904}
    1461 \end{ucppcode}&\begin{gocode}[tabsize=3]
     1905\end{uC++}&\begin{Go}[tabsize=3]
    14621906type MySem struct {
    14631907        inUse bool
     
    14791923        s.inUse = false
    14801924
    1481         //This actually deadlocks
    1482         //when single thread
     1925        // This actually deadlocks
     1926        // when single thread
    14831927        s.c <- false
    14841928}
    1485 \end{gocode}
     1929\end{Go}
    14861930\end{tabular}
    14871931\caption{Different forms of scheduling.}
    14881932\label{tbl:sched}
    14891933\end{table}
    1490 This method is more constrained and explicit, which helps users reduce the non-deterministic nature of concurrency. Indeed, as the following examples demonstrate, external scheduling allows users to wait for events from other threads without the concern of unrelated events occurring. External scheduling can generally be done either in terms of control flow (e.g., Ada with \code{accept}, \uC with \code{_Accept}) or in terms of data (e.g., Go with channels). Of course, both of these paradigms have their own strengths and weaknesses, but for this project, control-flow semantics was chosen to stay consistent with the rest of the languages semantics. Two challenges specific to \CFA arise when trying to add external scheduling with loose object definitions and multiple-monitor routines. The previous example shows a simple use \code{_Accept} versus \code{wait}/\code{signal} and its advantages. Note that while other languages often use \code{accept}/\code{select} as the core external scheduling keyword, \CFA uses \code{waitfor} to prevent name collisions with existing socket \textbf{api}s.
    1491 
    1492 For the \code{P} member above using internal scheduling, the call to \code{wait} only guarantees that \code{V} is the last routine to access the monitor, allowing a third routine, say \code{isInUse()}, acquire mutual exclusion several times while routine \code{P} is waiting. On the other hand, external scheduling guarantees that while routine \code{P} is waiting, no other routine than \code{V} can acquire the monitor.
     1934This method is more constrained and explicit, which helps users reduce the non-deterministic nature of concurrency.
     1935Indeed, as the following examples demonstrate, external scheduling allows users to wait for events from other threads without the concern of unrelated events occurring.
     1936External scheduling can generally be done either in terms of control flow (\eg Ada with @accept@, \uC with @_Accept@) or in terms of data (\eg Go with channels).
     1937Of course, both of these paradigms have their own strengths and weaknesses, but for this project, control-flow semantics was chosen to stay consistent with the rest of the languages semantics.
     1938Two challenges specific to \CFA arise when trying to add external scheduling with loose object definitions and multiple-monitor routines.
     1939The previous example shows a simple use @_Accept@ versus @wait@/@signal@ and its advantages.
     1940Note that while other languages often use @accept@/@select@ as the core external scheduling keyword, \CFA uses @waitfor@ to prevent name collisions with existing socket \textbf{api}s.
     1941
     1942For the @P@ member above using internal scheduling, the call to @wait@ only guarantees that @V@ is the last routine to access the monitor, allowing a third routine, say @isInUse()@, acquire mutual exclusion several times while routine @P@ is waiting.
     1943On the other hand, external scheduling guarantees that while routine @P@ is waiting, no other routine than @V@ can acquire the monitor.
    14931944
    14941945% ======================================================================
     
    14971948% ======================================================================
    14981949% ======================================================================
    1499 In \uC, a monitor class declaration includes an exhaustive list of monitor operations. Since \CFA is not object oriented, monitors become both more difficult to implement and less clear for a user:
    1500 
    1501 \begin{cfacode}
     1950In \uC, a monitor class declaration includes an exhaustive list of monitor operations.
     1951Since \CFA is not object oriented, monitors become both more difficult to implement and less clear for a user:
     1952
     1953\begin{cfa}
    15021954monitor A {};
    15031955
    15041956void f(A & mutex a);
    15051957void g(A & mutex a) {
    1506         waitfor(f); //Obvious which f() to wait for
    1507 }
    1508 
    1509 void f(A & mutex a, int); //New different F added in scope
     1958        waitfor(f); // Obvious which f() to wait for
     1959}
     1960
     1961void f(A & mutex a, int); // New different F added in scope
    15101962void h(A & mutex a) {
    1511         waitfor(f); //Less obvious which f() to wait for
    1512 }
    1513 \end{cfacode}
    1514 
    1515 Furthermore, external scheduling is an example where implementation constraints become visible from the interface. Here is the pseudo-code for the entering phase of a monitor:
     1963        waitfor(f); // Less obvious which f() to wait for
     1964}
     1965\end{cfa}
     1966
     1967Furthermore, external scheduling is an example where implementation constraints become visible from the interface.
     1968Here is the cfa-code for the entering phase of a monitor:
    15161969\begin{center}
    15171970\begin{tabular}{l}
    1518 \begin{pseudo}
     1971\begin{cfa}
    15191972        if monitor is free
    15201973                enter
     
    15251978        else
    15261979                block
    1527 \end{pseudo}
     1980\end{cfa}
    15281981\end{tabular}
    15291982\end{center}
    1530 For the first two conditions, it is easy to implement a check that can evaluate the condition in a few instructions. However, a fast check for \pscode{monitor accepts me} is much harder to implement depending on the constraints put on the monitors. Indeed, monitors are often expressed as an entry queue and some acceptor queue as in Figure~\ref{fig:ClassicalMonitor}.
     1983For the first two conditions, it is easy to implement a check that can evaluate the condition in a few instructions.
     1984However, a fast check for @monitor accepts me@ is much harder to implement depending on the constraints put on the monitors.
     1985Indeed, monitors are often expressed as an entry queue and some acceptor queue as in Figure~\ref{fig:ClassicalMonitor}.
    15311986
    15321987\begin{figure}
     
    15441999\end{figure}
    15452000
    1546 There are other alternatives to these pictures, but in the case of the left picture, implementing a fast accept check is relatively easy. Restricted to a fixed number of mutex members, N, the accept check reduces to updating a bitmask when the acceptor queue changes, a check that executes in a single instruction even with a fairly large number (e.g., 128) of mutex members. This approach requires a unique dense ordering of routines with an upper-bound and that ordering must be consistent across translation units. For OO languages these constraints are common, since objects only offer adding member routines consistently across translation units via inheritance. However, in \CFA users can extend objects with mutex routines that are only visible in certain translation unit. This means that establishing a program-wide dense-ordering among mutex routines can only be done in the program linking phase, and still could have issues when using dynamically shared objects.
     2001There are other alternatives to these pictures, but in the case of the left picture, implementing a fast accept check is relatively easy.
     2002Restricted to a fixed number of mutex members, N, the accept check reduces to updating a bitmask when the acceptor queue changes, a check that executes in a single instruction even with a fairly large number (\eg 128) of mutex members.
     2003This approach requires a unique dense ordering of routines with an upper-bound and that ordering must be consistent across translation units.
     2004For OO languages these constraints are common, since objects only offer adding member routines consistently across translation units via inheritance.
     2005However, in \CFA users can extend objects with mutex routines that are only visible in certain translation unit.
     2006This means that establishing a program-wide dense-ordering among mutex routines can only be done in the program linking phase, and still could have issues when using dynamically shared objects.
    15472007
    15482008The alternative is to alter the implementation as in Figure~\ref{fig:BulkMonitor}.
    1549 Here, the mutex routine called is associated with a thread on the entry queue while a list of acceptable routines is kept separate. Generating a mask dynamically means that the storage for the mask information can vary between calls to \code{waitfor}, allowing for more flexibility and extensions. Storing an array of accepted function pointers replaces the single instruction bitmask comparison with dereferencing a pointer followed by a linear search. Furthermore, supporting nested external scheduling (e.g., listing \ref{lst:nest-ext}) may now require additional searches for the \code{waitfor} statement to check if a routine is already queued.
     2009Here, the mutex routine called is associated with a thread on the entry queue while a list of acceptable routines is kept separate.
     2010Generating a mask dynamically means that the storage for the mask information can vary between calls to @waitfor@, allowing for more flexibility and extensions.
     2011Storing an array of accepted function pointers replaces the single instruction bitmask comparison with dereferencing a pointer followed by a linear search.
     2012Furthermore, supporting nested external scheduling (\eg listing \ref{f:nest-ext}) may now require additional searches for the @waitfor@ statement to check if a routine is already queued.
    15502013
    15512014\begin{figure}
    1552 \begin{cfacode}[caption={Example of nested external scheduling},label={lst:nest-ext}]
     2015\begin{cfa}[caption={Example of nested external scheduling},label={f:nest-ext}]
    15532016monitor M {};
    15542017void foo( M & mutex a ) {}
    15552018void bar( M & mutex b ) {
    1556         //Nested in the waitfor(bar, c) call
     2019        // Nested in the waitfor(bar, c) call
    15572020        waitfor(foo, b);
    15582021}
     
    15612024}
    15622025
    1563 \end{cfacode}
     2026\end{cfa}
    15642027\end{figure}
    15652028
    1566 Note that in the right picture, tasks need to always keep track of the monitors associated with mutex routines, and the routine mask needs to have both a function pointer and a set of monitors, as is discussed in the next section. These details are omitted from the picture for the sake of simplicity.
    1567 
    1568 At this point, a decision must be made between flexibility and performance. Many design decisions in \CFA achieve both flexibility and performance, for example polymorphic routines add significant flexibility but inlining them means the optimizer can easily remove any runtime cost. Here, however, the cost of flexibility cannot be trivially removed. In the end, the most flexible approach has been chosen since it allows users to write programs that would otherwise be  hard to write. This decision is based on the assumption that writing fast but inflexible locks is closer to a solved problem than writing locks that are as flexible as external scheduling in \CFA.
     2029Note that in the right picture, tasks need to always keep track of the monitors associated with mutex routines, and the routine mask needs to have both a function pointer and a set of monitors, as is discussed in the next section.
     2030These details are omitted from the picture for the sake of simplicity.
     2031
     2032At this point, a decision must be made between flexibility and performance.
     2033Many design decisions in \CFA achieve both flexibility and performance, for example polymorphic routines add significant flexibility but inlining them means the optimizer can easily remove any runtime cost.
     2034Here, however, the cost of flexibility cannot be trivially removed.
     2035In the end, the most flexible approach has been chosen since it allows users to write programs that would otherwise be  hard to write.
     2036This decision is based on the assumption that writing fast but inflexible locks is closer to a solved problem than writing locks that are as flexible as external scheduling in \CFA.
    15692037
    15702038% ======================================================================
     
    15742042% ======================================================================
    15752043
    1576 External scheduling, like internal scheduling, becomes significantly more complex when introducing multi-monitor syntax. Even in the simplest possible case, some new semantics needs to be established:
    1577 \begin{cfacode}
     2044External scheduling, like internal scheduling, becomes significantly more complex when introducing multi-monitor syntax.
     2045Even in the simplest possible case, some new semantics needs to be established:
     2046\begin{cfa}
    15782047monitor M {};
    15792048
     
    15812050
    15822051void g(M & mutex b, M & mutex c) {
    1583         waitfor(f); //two monitors M => unknown which to pass to f(M & mutex)
    1584 }
    1585 \end{cfacode}
     2052        waitfor(f); // two monitors M => unknown which to pass to f(M & mutex)
     2053}
     2054\end{cfa}
    15862055The obvious solution is to specify the correct monitor as follows:
    15872056
    1588 \begin{cfacode}
     2057\begin{cfa}
    15892058monitor M {};
    15902059
     
    15922061
    15932062void g(M & mutex a, M & mutex b) {
    1594         //wait for call to f with argument b
     2063        // wait for call to f with argument b
    15952064        waitfor(f, b);
    15962065}
    1597 \end{cfacode}
    1598 This syntax is unambiguous. Both locks are acquired and kept by \code{g}. When routine \code{f} is called, the lock for monitor \code{b} is temporarily transferred from \code{g} to \code{f} (while \code{g} still holds lock \code{a}). This behaviour can be extended to the multi-monitor \code{waitfor} statement as follows.
    1599 
    1600 \begin{cfacode}
     2066\end{cfa}
     2067This syntax is unambiguous.
     2068Both locks are acquired and kept by @g@.
     2069When routine @f@ is called, the lock for monitor @b@ is temporarily transferred from @g@ to @f@ (while @g@ still holds lock @a@).
     2070This behaviour can be extended to the multi-monitor @waitfor@ statement as follows.
     2071
     2072\begin{cfa}
    16012073monitor M {};
    16022074
     
    16042076
    16052077void g(M & mutex a, M & mutex b) {
    1606         //wait for call to f with arguments a and b
     2078        // wait for call to f with arguments a and b
    16072079        waitfor(f, a, b);
    16082080}
    1609 \end{cfacode}
    1610 
    1611 Note that the set of monitors passed to the \code{waitfor} statement must be entirely contained in the set of monitors already acquired in the routine. \code{waitfor} used in any other context is undefined behaviour.
     2081\end{cfa}
     2082
     2083Note that the set of monitors passed to the @waitfor@ statement must be entirely contained in the set of monitors already acquired in the routine. @waitfor@ used in any other context is undefined behaviour.
    16122084
    16132085An important behaviour to note is when a set of monitors only match partially:
    16142086
    1615 \begin{cfacode}
     2087\begin{cfa}
    16162088mutex struct A {};
    16172089
     
    16262098
    16272099void foo() {
    1628         g(a1, b); //block on accept
     2100        g(a1, b); // block on accept
    16292101}
    16302102
    16312103void bar() {
    1632         f(a2, b); //fulfill cooperation
    1633 }
    1634 \end{cfacode}
    1635 While the equivalent can happen when using internal scheduling, the fact that conditions are specific to a set of monitors means that users have to use two different condition variables. In both cases, partially matching monitor sets does not wakeup the waiting thread. It is also important to note that in the case of external scheduling the order of parameters is irrelevant; \code{waitfor(f,a,b)} and \code{waitfor(f,b,a)} are indistinguishable waiting condition.
    1636 
    1637 % ======================================================================
    1638 % ======================================================================
    1639 \subsection{\code{waitfor} Semantics}
    1640 % ======================================================================
    1641 % ======================================================================
    1642 
    1643 Syntactically, the \code{waitfor} statement takes a function identifier and a set of monitors. While the set of monitors can be any list of expressions, the function name is more restricted because the compiler validates at compile time the validity of the function type and the parameters used with the \code{waitfor} statement. It checks that the set of monitors passed in matches the requirements for a function call. Listing \ref{lst:waitfor} shows various usages of the waitfor statement and which are acceptable. The choice of the function type is made ignoring any non-\code{mutex} parameter. One limitation of the current implementation is that it does not handle overloading, but overloading is possible.
     2104        f(a2, b); // fulfill cooperation
     2105}
     2106\end{cfa}
     2107While the equivalent can happen when using internal scheduling, the fact that conditions are specific to a set of monitors means that users have to use two different condition variables.
     2108In both cases, partially matching monitor sets does not wakeup the waiting thread.
     2109It is also important to note that in the case of external scheduling the order of parameters is irrelevant; @waitfor(f,a,b)@ and @waitfor(f,b,a)@ are indistinguishable waiting condition.
     2110
     2111% ======================================================================
     2112% ======================================================================
     2113\subsection{\protect\lstinline|waitfor| Semantics}
     2114% ======================================================================
     2115% ======================================================================
     2116
     2117Syntactically, the @waitfor@ statement takes a function identifier and a set of monitors.
     2118While the set of monitors can be any list of expressions, the function name is more restricted because the compiler validates at compile time the validity of the function type and the parameters used with the @waitfor@ statement.
     2119It checks that the set of monitors passed in matches the requirements for a function call.
     2120Figure~\ref{f:waitfor} shows various usages of the waitfor statement and which are acceptable.
     2121The choice of the function type is made ignoring any non-@mutex@ parameter.
     2122One limitation of the current implementation is that it does not handle overloading, but overloading is possible.
    16442123\begin{figure}
    1645 \begin{cfacode}[caption={Various correct and incorrect uses of the waitfor statement},label={lst:waitfor}]
     2124\begin{cfa}[caption={Various correct and incorrect uses of the waitfor statement},label={f:waitfor}]
    16462125monitor A{};
    16472126monitor B{};
     
    16572136        void (*fp)( A & mutex ) = f1;
    16582137
    1659         waitfor(f1, a1);     //Correct : 1 monitor case
    1660         waitfor(f2, a1, b1); //Correct : 2 monitor case
    1661         waitfor(f3, a1);     //Correct : non-mutex arguments are ignored
    1662         waitfor(f1, *ap);    //Correct : expression as argument
    1663 
    1664         waitfor(f1, a1, b1); //Incorrect : Too many mutex arguments
    1665         waitfor(f2, a1);     //Incorrect : Too few mutex arguments
    1666         waitfor(f2, a1, a2); //Incorrect : Mutex arguments don't match
    1667         waitfor(f1, 1);      //Incorrect : 1 not a mutex argument
    1668         waitfor(f9, a1);     //Incorrect : f9 function does not exist
    1669         waitfor(*fp, a1 );   //Incorrect : fp not an identifier
    1670         waitfor(f4, a1);     //Incorrect : f4 ambiguous
    1671 
    1672         waitfor(f2, a1, b2); //Undefined behaviour : b2 not mutex
    1673 }
    1674 \end{cfacode}
     2138        waitfor(f1, a1);     // Correct : 1 monitor case
     2139        waitfor(f2, a1, b1); // Correct : 2 monitor case
     2140        waitfor(f3, a1);     // Correct : non-mutex arguments are ignored
     2141        waitfor(f1, *ap);    // Correct : expression as argument
     2142
     2143        waitfor(f1, a1, b1); // Incorrect : Too many mutex arguments
     2144        waitfor(f2, a1);     // Incorrect : Too few mutex arguments
     2145        waitfor(f2, a1, a2); // Incorrect : Mutex arguments don't match
     2146        waitfor(f1, 1);      // Incorrect : 1 not a mutex argument
     2147        waitfor(f9, a1);     // Incorrect : f9 function does not exist
     2148        waitfor(*fp, a1 );   // Incorrect : fp not an identifier
     2149        waitfor(f4, a1);     // Incorrect : f4 ambiguous
     2150
     2151        waitfor(f2, a1, b2); // Undefined behaviour : b2 not mutex
     2152}
     2153\end{cfa}
    16752154\end{figure}
    16762155
    1677 Finally, for added flexibility, \CFA supports constructing a complex \code{waitfor} statement using the \code{or}, \code{timeout} and \code{else}. Indeed, multiple \code{waitfor} clauses can be chained together using \code{or}; this chain forms a single statement that uses baton pass to any function that fits one of the function+monitor set passed in. To enable users to tell which accepted function executed, \code{waitfor}s are followed by a statement (including the null statement \code{;}) or a compound statement, which is executed after the clause is triggered. A \code{waitfor} chain can also be followed by a \code{timeout}, to signify an upper bound on the wait, or an \code{else}, to signify that the call should be non-blocking, which checks for a matching function call already arrived and otherwise continues. Any and all of these clauses can be preceded by a \code{when} condition to dynamically toggle the accept clauses on or off based on some current state. Listing \ref{lst:waitfor2} demonstrates several complex masks and some incorrect ones.
     2156Finally, for added flexibility, \CFA supports constructing a complex @waitfor@ statement using the @or@, @timeout@ and @else@.
     2157Indeed, multiple @waitfor@ clauses can be chained together using @or@; this chain forms a single statement that uses baton pass to any function that fits one of the function+monitor set passed in.
     2158To enable users to tell which accepted function executed, @waitfor@s are followed by a statement (including the null statement @;@) or a compound statement, which is executed after the clause is triggered.
     2159A @waitfor@ chain can also be followed by a @timeout@, to signify an upper bound on the wait, or an @else@, to signify that the call should be non-blocking, which checks for a matching function call already arrived and otherwise continues.
     2160Any and all of these clauses can be preceded by a @when@ condition to dynamically toggle the accept clauses on or off based on some current state.
     2161Figure~\ref{f:waitfor2} demonstrates several complex masks and some incorrect ones.
    16782162
    16792163\begin{figure}
    1680 \begin{cfacode}[caption={Various correct and incorrect uses of the or, else, and timeout clause around a waitfor statement},label={lst:waitfor2}]
     2164\lstset{language=CFA,deletedelim=**[is][]{`}{`}}
     2165\begin{cfa}
    16812166monitor A{};
    16822167
     
    16852170
    16862171void foo( A & mutex a, bool b, int t ) {
    1687         //Correct : blocking case
    1688         waitfor(f1, a);
    1689 
    1690         //Correct : block with statement
    1691         waitfor(f1, a) {
     2172        waitfor(f1, a);                                                 $\C{// Correct : blocking case}$
     2173
     2174        waitfor(f1, a) {                                                $\C{// Correct : block with statement}$
    16922175                sout | "f1" | endl;
    16932176        }
    1694 
    1695         //Correct : block waiting for f1 or f2
    1696         waitfor(f1, a) {
     2177        waitfor(f1, a) {                                                $\C{// Correct : block waiting for f1 or f2}$
    16972178                sout | "f1" | endl;
    16982179        } or waitfor(f2, a) {
    16992180                sout | "f2" | endl;
    17002181        }
    1701 
    1702         //Correct : non-blocking case
    1703         waitfor(f1, a); or else;
    1704 
    1705         //Correct : non-blocking case
    1706         waitfor(f1, a) {
     2182        waitfor(f1, a); or else;                                $\C{// Correct : non-blocking case}$
     2183
     2184        waitfor(f1, a) {                                                $\C{// Correct : non-blocking case}$
    17072185                sout | "blocked" | endl;
    17082186        } or else {
    17092187                sout | "didn't block" | endl;
    17102188        }
    1711 
    1712         //Correct : block at most 10 seconds
    1713         waitfor(f1, a) {
     2189        waitfor(f1, a) {                                                $\C{// Correct : block at most 10 seconds}$
    17142190                sout | "blocked" | endl;
    17152191        } or timeout( 10`s) {
    17162192                sout | "didn't block" | endl;
    17172193        }
    1718 
    1719         //Correct : block only if b == true
    1720         //if b == false, don't even make the call
     2194        // Correct : block only if b == true if b == false, don't even make the call
    17212195        when(b) waitfor(f1, a);
    17222196
    1723         //Correct : block only if b == true
    1724         //if b == false, make non-blocking call
     2197        // Correct : block only if b == true if b == false, make non-blocking call
    17252198        waitfor(f1, a); or when(!b) else;
    17262199
    1727         //Correct : block only of t > 1
     2200        // Correct : block only of t > 1
    17282201        waitfor(f1, a); or when(t > 1) timeout(t); or else;
    17292202
    1730         //Incorrect : timeout clause is dead code
     2203        // Incorrect : timeout clause is dead code
    17312204        waitfor(f1, a); or timeout(t); or else;
    17322205
    1733         //Incorrect : order must be
    1734         //waitfor [or waitfor... [or timeout] [or else]]
     2206        // Incorrect : order must be waitfor [or waitfor... [or timeout] [or else]]
    17352207        timeout(t); or waitfor(f1, a); or else;
    17362208}
    1737 \end{cfacode}
     2209\end{cfa}
     2210\caption{Correct and incorrect uses of the or, else, and timeout clause around a waitfor statement}
     2211\label{f:waitfor2}
    17382212\end{figure}
    17392213
     
    17432217% ======================================================================
    17442218% ======================================================================
    1745 An interesting use for the \code{waitfor} statement is destructor semantics. Indeed, the \code{waitfor} statement can accept any \code{mutex} routine, which includes the destructor (see section \ref{data}). However, with the semantics discussed until now, waiting for the destructor does not make any sense, since using an object after its destructor is called is undefined behaviour. The simplest approach is to disallow \code{waitfor} on a destructor. However, a more expressive approach is to flip ordering of execution when waiting for the destructor, meaning that waiting for the destructor allows the destructor to run after the current \code{mutex} routine, similarly to how a condition is signalled.
     2219An interesting use for the @waitfor@ statement is destructor semantics.
     2220Indeed, the @waitfor@ statement can accept any @mutex@ routine, which includes the destructor (see section \ref{data}).
     2221However, with the semantics discussed until now, waiting for the destructor does not make any sense, since using an object after its destructor is called is undefined behaviour.
     2222The simplest approach is to disallow @waitfor@ on a destructor.
     2223However, a more expressive approach is to flip ordering of execution when waiting for the destructor, meaning that waiting for the destructor allows the destructor to run after the current @mutex@ routine, similarly to how a condition is signalled.
    17462224\begin{figure}
    1747 \begin{cfacode}[caption={Example of an executor which executes action in series until the destructor is called.},label={lst:dtor-order}]
     2225\begin{cfa}[caption={Example of an executor which executes action in series until the destructor is called.},label={f:dtor-order}]
    17482226monitor Executer {};
    17492227struct  Action;
     
    17592237        }
    17602238}
    1761 \end{cfacode}
     2239\end{cfa}
    17622240\end{figure}
    1763 For example, listing \ref{lst:dtor-order} shows an example of an executor with an infinite loop, which waits for the destructor to break out of this loop. Switching the semantic meaning introduces an idiomatic way to terminate a task and/or wait for its termination via destruction.
     2241For example, listing \ref{f:dtor-order} shows an example of an executor with an infinite loop, which waits for the destructor to break out of this loop.
     2242Switching the semantic meaning introduces an idiomatic way to terminate a task and/or wait for its termination via destruction.
    17642243
    17652244
     
    17722251% #       #     # #     # #     # ####### ####### ####### ####### ###  #####  #     #
    17732252\section{Parallelism}
    1774 Historically, computer performance was about processor speeds and instruction counts. However, with heat dissipation being a direct consequence of speed increase, parallelism has become the new source for increased performance~\cite{Sutter05, Sutter05b}. In this decade, it is no longer reasonable to create a high-performance application without caring about parallelism. Indeed, parallelism is an important aspect of performance and more specifically throughput and hardware utilization. The lowest-level approach of parallelism is to use \textbf{kthread} in combination with semantics like \code{fork}, \code{join}, etc. However, since these have significant costs and limitations, \textbf{kthread} are now mostly used as an implementation tool rather than a user oriented one. There are several alternatives to solve these issues that all have strengths and weaknesses. While there are many variations of the presented paradigms, most of these variations do not actually change the guarantees or the semantics, they simply move costs in order to achieve better performance for certain workloads.
     2253Historically, computer performance was about processor speeds and instruction counts.
     2254However, with heat dissipation being a direct consequence of speed increase, parallelism has become the new source for increased performance~\cite{Sutter05, Sutter05b}.
     2255In this decade, it is no longer reasonable to create a high-performance application without caring about parallelism.
     2256Indeed, parallelism is an important aspect of performance and more specifically throughput and hardware utilization.
     2257The lowest-level approach of parallelism is to use \textbf{kthread} in combination with semantics like @fork@, @join@, \etc.
     2258However, since these have significant costs and limitations, \textbf{kthread} are now mostly used as an implementation tool rather than a user oriented one.
     2259There are several alternatives to solve these issues that all have strengths and weaknesses.
     2260While there are many variations of the presented paradigms, most of these variations do not actually change the guarantees or the semantics, they simply move costs in order to achieve better performance for certain workloads.
    17752261
    17762262\section{Paradigms}
    17772263\subsection{User-Level Threads}
    1778 A direct improvement on the \textbf{kthread} approach is to use \textbf{uthread}. These threads offer most of the same features that the operating system already provides but can be used on a much larger scale. This approach is the most powerful solution as it allows all the features of multithreading, while removing several of the more expensive costs of kernel threads. The downside is that almost none of the low-level threading problems are hidden; users still have to think about data races, deadlocks and synchronization issues. These issues can be somewhat alleviated by a concurrency toolkit with strong guarantees, but the parallelism toolkit offers very little to reduce complexity in itself.
     2264A direct improvement on the \textbf{kthread} approach is to use \textbf{uthread}.
     2265These threads offer most of the same features that the operating system already provides but can be used on a much larger scale.
     2266This approach is the most powerful solution as it allows all the features of multithreading, while removing several of the more expensive costs of kernel threads.
     2267The downside is that almost none of the low-level threading problems are hidden; users still have to think about data races, deadlocks and synchronization issues.
     2268These issues can be somewhat alleviated by a concurrency toolkit with strong guarantees, but the parallelism toolkit offers very little to reduce complexity in itself.
    17792269
    17802270Examples of languages that support \textbf{uthread} are Erlang~\cite{Erlang} and \uC~\cite{uC++book}.
    17812271
    17822272\subsection{Fibers : User-Level Threads Without Preemption} \label{fibers}
    1783 A popular variant of \textbf{uthread} is what is often referred to as \textbf{fiber}. However, \textbf{fiber} do not present meaningful semantic differences with \textbf{uthread}. The significant difference between \textbf{uthread} and \textbf{fiber} is the lack of \textbf{preemption} in the latter. Advocates of \textbf{fiber} list their high performance and ease of implementation as major strengths, but the performance difference between \textbf{uthread} and \textbf{fiber} is controversial, and the ease of implementation, while true, is a weak argument in the context of language design. Therefore this proposal largely ignores fibers.
     2273A popular variant of \textbf{uthread} is what is often referred to as \textbf{fiber}.
     2274However, \textbf{fiber} do not present meaningful semantic differences with \textbf{uthread}.
     2275The significant difference between \textbf{uthread} and \textbf{fiber} is the lack of \textbf{preemption} in the latter.
     2276Advocates of \textbf{fiber} list their high performance and ease of implementation as major strengths, but the performance difference between \textbf{uthread} and \textbf{fiber} is controversial, and the ease of implementation, while true, is a weak argument in the context of language design.
     2277Therefore this proposal largely ignores fibers.
    17842278
    17852279An example of a language that uses fibers is Go~\cite{Go}
    17862280
    17872281\subsection{Jobs and Thread Pools}
    1788 An approach on the opposite end of the spectrum is to base parallelism on \textbf{pool}. Indeed, \textbf{pool} offer limited flexibility but at the benefit of a simpler user interface. In \textbf{pool} based systems, users express parallelism as units of work, called jobs, and a dependency graph (either explicit or implicit) that ties them together. This approach means users need not worry about concurrency but significantly limit the interaction that can occur among jobs. Indeed, any \textbf{job} that blocks also block the underlying worker, which effectively means the CPU utilization, and therefore throughput, suffers noticeably. It can be argued that a solution to this problem is to use more workers than available cores. However, unless the number of jobs and the number of workers are comparable, having a significant number of blocked jobs always results in idles cores.
     2282An approach on the opposite end of the spectrum is to base parallelism on \textbf{pool}.
     2283Indeed, \textbf{pool} offer limited flexibility but at the benefit of a simpler user interface.
     2284In \textbf{pool} based systems, users express parallelism as units of work, called jobs, and a dependency graph (either explicit or implicit) that ties them together.
     2285This approach means users need not worry about concurrency but significantly limit the interaction that can occur among jobs.
     2286Indeed, any \textbf{job} that blocks also block the underlying worker, which effectively means the CPU utilization, and therefore throughput, suffers noticeably.
     2287It can be argued that a solution to this problem is to use more workers than available cores.
     2288However, unless the number of jobs and the number of workers are comparable, having a significant number of blocked jobs always results in idles cores.
    17892289
    17902290The gold standard of this implementation is Intel's TBB library~\cite{TBB}.
    17912291
    17922292\subsection{Paradigm Performance}
    1793 While the choice between the three paradigms listed above may have significant performance implications, it is difficult to pin down the performance implications of choosing a model at the language level. Indeed, in many situations one of these paradigms may show better performance but it all strongly depends on the workload. Having a large amount of mostly independent units of work to execute almost guarantees equivalent performance across paradigms and that the \textbf{pool}-based system has the best efficiency thanks to the lower memory overhead (i.e., no thread stack per job). However, interactions among jobs can easily exacerbate contention. User-level threads allow fine-grain context switching, which results in better resource utilization, but a context switch is more expensive and the extra control means users need to tweak more variables to get the desired performance. Finally, if the units of uninterrupted work are large, enough the paradigm choice is largely amortized by the actual work done.
     2293While the choice between the three paradigms listed above may have significant performance implications, it is difficult to pin down the performance implications of choosing a model at the language level.
     2294Indeed, in many situations one of these paradigms may show better performance but it all strongly depends on the workload.
     2295Having a large amount of mostly independent units of work to execute almost guarantees equivalent performance across paradigms and that the \textbf{pool}-based system has the best efficiency thanks to the lower memory overhead (\ie no thread stack per job).
     2296However, interactions among jobs can easily exacerbate contention.
     2297User-level threads allow fine-grain context switching, which results in better resource utilization, but a context switch is more expensive and the extra control means users need to tweak more variables to get the desired performance.
     2298Finally, if the units of uninterrupted work are large, enough the paradigm choice is largely amortized by the actual work done.
    17942299
    17952300\section{The \protect\CFA\ Kernel : Processors, Clusters and Threads}\label{kernel}
    1796 A \textbf{cfacluster} is a group of \textbf{kthread} executed in isolation. \textbf{uthread} are scheduled on the \textbf{kthread} of a given \textbf{cfacluster}, allowing organization between \textbf{uthread} and \textbf{kthread}. It is important that \textbf{kthread} belonging to a same \textbf{cfacluster} have homogeneous settings, otherwise migrating a \textbf{uthread} from one \textbf{kthread} to the other can cause issues. A \textbf{cfacluster} also offers a pluggable scheduler that can optimize the workload generated by the \textbf{uthread}.
    1797 
    1798 \textbf{cfacluster} have not been fully implemented in the context of this paper. Currently \CFA only supports one \textbf{cfacluster}, the initial one.
     2301A \textbf{cfacluster} is a group of \textbf{kthread} executed in isolation. \textbf{uthread} are scheduled on the \textbf{kthread} of a given \textbf{cfacluster}, allowing organization between \textbf{uthread} and \textbf{kthread}.
     2302It is important that \textbf{kthread} belonging to a same \textbf{cfacluster} have homogeneous settings, otherwise migrating a \textbf{uthread} from one \textbf{kthread} to the other can cause issues.
     2303A \textbf{cfacluster} also offers a pluggable scheduler that can optimize the workload generated by the \textbf{uthread}.
     2304
     2305\textbf{cfacluster} have not been fully implemented in the context of this paper.
     2306Currently \CFA only supports one \textbf{cfacluster}, the initial one.
    17992307
    18002308\subsection{Future Work: Machine Setup}\label{machine}
    1801 While this was not done in the context of this paper, another important aspect of clusters is affinity. While many common desktop and laptop PCs have homogeneous CPUs, other devices often have more heterogeneous setups. For example, a system using \textbf{numa} configurations may benefit from users being able to tie clusters and/or kernel threads to certain CPU cores. OS support for CPU affinity is now common~\cite{affinityLinux, affinityWindows, affinityFreebsd, affinityNetbsd, affinityMacosx}, which means it is both possible and desirable for \CFA to offer an abstraction mechanism for portable CPU affinity.
     2309While this was not done in the context of this paper, another important aspect of clusters is affinity.
     2310While many common desktop and laptop PCs have homogeneous CPUs, other devices often have more heterogeneous setups.
     2311For example, a system using \textbf{numa} configurations may benefit from users being able to tie clusters and/or kernel threads to certain CPU cores.
     2312OS support for CPU affinity is now common~\cite{affinityLinux, affinityWindows, affinityFreebsd, affinityNetbsd, affinityMacosx}, which means it is both possible and desirable for \CFA to offer an abstraction mechanism for portable CPU affinity.
    18022313
    18032314\subsection{Paradigms}\label{cfaparadigms}
    1804 Given these building blocks, it is possible to reproduce all three of the popular paradigms. Indeed, \textbf{uthread} is the default paradigm in \CFA. However, disabling \textbf{preemption} on the \textbf{cfacluster} means \textbf{cfathread} effectively become \textbf{fiber}. Since several \textbf{cfacluster} with different scheduling policy can coexist in the same application, this allows \textbf{fiber} and \textbf{uthread} to coexist in the runtime of an application. Finally, it is possible to build executors for thread pools from \textbf{uthread} or \textbf{fiber}, which includes specialized jobs like actors~\cite{Actors}.
     2315Given these building blocks, it is possible to reproduce all three of the popular paradigms.
     2316Indeed, \textbf{uthread} is the default paradigm in \CFA.
     2317However, disabling \textbf{preemption} on the \textbf{cfacluster} means \textbf{cfathread} effectively become \textbf{fiber}.
     2318Since several \textbf{cfacluster} with different scheduling policy can coexist in the same application, this allows \textbf{fiber} and \textbf{uthread} to coexist in the runtime of an application.
     2319Finally, it is possible to build executors for thread pools from \textbf{uthread} or \textbf{fiber}, which includes specialized jobs like actors~\cite{Actors}.
    18052320
    18062321
    18072322
    18082323\section{Behind the Scenes}
    1809 There are several challenges specific to \CFA when implementing concurrency. These challenges are a direct result of \textbf{bulk-acq} and loose object definitions. These two constraints are the root cause of most design decisions in the implementation. Furthermore, to avoid contention from dynamically allocating memory in a concurrent environment, the internal-scheduling design is (almost) entirely free of mallocs. This approach avoids the chicken and egg problem~\cite{Chicken} of having a memory allocator that relies on the threading system and a threading system that relies on the runtime. This extra goal means that memory management is a constant concern in the design of the system.
    1810 
    1811 The main memory concern for concurrency is queues. All blocking operations are made by parking threads onto queues and all queues are designed with intrusive nodes, where each node has pre-allocated link fields for chaining, to avoid the need for memory allocation. Since several concurrency operations can use an unbound amount of memory (depending on \textbf{bulk-acq}), statically defining information in the intrusive fields of threads is insufficient.The only way to use a variable amount of memory without requiring memory allocation is to pre-allocate large buffers of memory eagerly and store the information in these buffers. Conveniently, the call stack fits that description and is easy to use, which is why it is used heavily in the implementation of internal scheduling, particularly variable-length arrays. Since stack allocation is based on scopes, the first step of the implementation is to identify the scopes that are available to store the information, and which of these can have a variable-length array. The threads and the condition both have a fixed amount of memory, while \code{mutex} routines and blocking calls allow for an unbound amount, within the stack size.
     2324There are several challenges specific to \CFA when implementing concurrency.
     2325These challenges are a direct result of \textbf{bulk-acq} and loose object definitions.
     2326These two constraints are the root cause of most design decisions in the implementation.
     2327Furthermore, to avoid contention from dynamically allocating memory in a concurrent environment, the internal-scheduling design is (almost) entirely free of mallocs.
     2328This approach avoids the chicken and egg problem~\cite{Chicken} of having a memory allocator that relies on the threading system and a threading system that relies on the runtime.
     2329This extra goal means that memory management is a constant concern in the design of the system.
     2330
     2331The main memory concern for concurrency is queues.
     2332All blocking operations are made by parking threads onto queues and all queues are designed with intrusive nodes, where each node has pre-allocated link fields for chaining, to avoid the need for memory allocation.
     2333Since several concurrency operations can use an unbound amount of memory (depending on \textbf{bulk-acq}), statically defining information in the intrusive fields of threads is insufficient.The only way to use a variable amount of memory without requiring memory allocation is to pre-allocate large buffers of memory eagerly and store the information in these buffers.
     2334Conveniently, the call stack fits that description and is easy to use, which is why it is used heavily in the implementation of internal scheduling, particularly variable-length arrays.
     2335Since stack allocation is based on scopes, the first step of the implementation is to identify the scopes that are available to store the information, and which of these can have a variable-length array.
     2336The threads and the condition both have a fixed amount of memory, while @mutex@ routines and blocking calls allow for an unbound amount, within the stack size.
    18122337
    18132338Note that since the major contributions of this paper are extending monitor semantics to \textbf{bulk-acq} and loose object definitions, any challenges that are not resulting of these characteristics of \CFA are considered as solved problems and therefore not discussed.
     
    18192344% ======================================================================
    18202345
    1821 The first step towards the monitor implementation is simple \code{mutex} routines. In the single monitor case, mutual-exclusion is done using the entry/exit procedure in listing \ref{lst:entry1}. The entry/exit procedures do not have to be extended to support multiple monitors. Indeed it is sufficient to enter/leave monitors one-by-one as long as the order is correct to prevent deadlock~\cite{Havender68}. In \CFA, ordering of monitor acquisition relies on memory ordering. This approach is sufficient because all objects are guaranteed to have distinct non-overlapping memory layouts and mutual-exclusion for a monitor is only defined for its lifetime, meaning that destroying a monitor while it is acquired is undefined behaviour. When a mutex call is made, the concerned monitors are aggregated into a variable-length pointer array and sorted based on pointer values. This array persists for the entire duration of the mutual-exclusion and its ordering reused extensively.
     2346The first step towards the monitor implementation is simple @mutex@ routines.
     2347In the single monitor case, mutual-exclusion is done using the entry/exit procedure in listing \ref{f:entry1}.
     2348The entry/exit procedures do not have to be extended to support multiple monitors.
     2349Indeed it is sufficient to enter/leave monitors one-by-one as long as the order is correct to prevent deadlock~\cite{Havender68}.
     2350In \CFA, ordering of monitor acquisition relies on memory ordering.
     2351This approach is sufficient because all objects are guaranteed to have distinct non-overlapping memory layouts and mutual-exclusion for a monitor is only defined for its lifetime, meaning that destroying a monitor while it is acquired is undefined behaviour.
     2352When a mutex call is made, the concerned monitors are aggregated into a variable-length pointer array and sorted based on pointer values.
     2353This array persists for the entire duration of the mutual-exclusion and its ordering reused extensively.
    18222354\begin{figure}
    18232355\begin{multicols}{2}
    18242356Entry
    1825 \begin{pseudo}
     2357\begin{cfa}
    18262358if monitor is free
    18272359        enter
     
    18312363        block
    18322364increment recursions
    1833 \end{pseudo}
     2365\end{cfa}
    18342366\columnbreak
    18352367Exit
    1836 \begin{pseudo}
     2368\begin{cfa}
    18372369decrement recursion
    18382370if recursion == 0
    18392371        if entry queue not empty
    18402372                wake-up thread
    1841 \end{pseudo}
     2373\end{cfa}
    18422374\end{multicols}
    1843 \begin{pseudo}[caption={Initial entry and exit routine for monitors},label={lst:entry1}]
    1844 \end{pseudo}
     2375\begin{cfa}[caption={Initial entry and exit routine for monitors},label={f:entry1}]
     2376\end{cfa}
    18452377\end{figure}
    18462378
    18472379\subsection{Details: Interaction with polymorphism}
    1848 Depending on the choice of semantics for when monitor locks are acquired, interaction between monitors and \CFA's concept of polymorphism can be more complex to support. However, it is shown that entry-point locking solves most of the issues.
    1849 
    1850 First of all, interaction between \code{otype} polymorphism (see Section~\ref{s:ParametricPolymorphism}) and monitors is impossible since monitors do not support copying. Therefore, the main question is how to support \code{dtype} polymorphism. It is important to present the difference between the two acquiring options: \textbf{callsite-locking} 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:
    1851 \begin{table}[H]
     2380Depending on the choice of semantics for when monitor locks are acquired, interaction between monitors and \CFA's concept of polymorphism can be more complex to support.
     2381However, it is shown that entry-point locking solves most of the issues.
     2382
     2383First of all, interaction between @otype@ polymorphism (see Section~\ref{s:ParametricPolymorphism}) and monitors is impossible since monitors do not support copying.
     2384Therefore, the main question is how to support @dtype@ polymorphism.
     2385It is important to present the difference between the two acquiring options: \textbf{callsite-locking} and entry-point locking, \ie acquiring the monitors before making a mutex routine-call or as the first operation of the mutex routine-call.
     2386For example:
     2387\begin{table}
    18522388\begin{center}
    18532389\begin{tabular}{|c|c|c|}
    18542390Mutex & \textbf{callsite-locking} & \textbf{entry-point-locking} \\
    1855 call & pseudo-code & pseudo-code \\
     2391call & cfa-code & cfa-code \\
    18562392\hline
    1857 \begin{cfacode}[tabsize=3]
     2393\begin{cfa}[tabsize=3]
    18582394void foo(monitor& mutex a){
    18592395
    1860         //Do Work
     2396        // Do Work
    18612397        //...
    18622398
     
    18692405
    18702406}
    1871 \end{cfacode} & \begin{pseudo}[tabsize=3]
     2407\end{cfa} & \begin{cfa}[tabsize=3]
    18722408foo(& a) {
    18732409
    1874         //Do Work
     2410        // Do Work
    18752411        //...
    18762412
     
    18832419        release(a);
    18842420}
    1885 \end{pseudo} & \begin{pseudo}[tabsize=3]
     2421\end{cfa} & \begin{cfa}[tabsize=3]
    18862422foo(& a) {
    18872423        acquire(a);
    1888         //Do Work
     2424        // Do Work
    18892425        //...
    18902426        release(a);
     
    18972433
    18982434}
    1899 \end{pseudo}
     2435\end{cfa}
    19002436\end{tabular}
    19012437\end{center}
     
    19042440\end{table}
    19052441
    1906 Note the \code{mutex} keyword relies on the type system, which means that in cases where a generic monitor-routine is desired, writing the mutex routine is possible with the proper trait, e.g.:
    1907 \begin{cfacode}
    1908 //Incorrect: T may not be monitor
     2442Note the @mutex@ keyword relies on the type system, which means that in cases where a generic monitor-routine is desired, writing the mutex routine is possible with the proper trait, \eg:
     2443\begin{cfa}
     2444// Incorrect: T may not be monitor
    19092445forall(dtype T)
    19102446void foo(T * mutex t);
    19112447
    1912 //Correct: this function only works on monitors (any monitor)
     2448// Correct: this function only works on monitors (any monitor)
    19132449forall(dtype T | is_monitor(T))
    19142450void bar(T * mutex t));
    1915 \end{cfacode}
    1916 
    1917 Both entry point and \textbf{callsite-locking} are feasible implementations. The current \CFA implementation uses entry-point locking because it requires less work when using \textbf{raii}, effectively transferring the burden of implementation to object construction/destruction. It is harder to use \textbf{raii} for call-site locking, as it does not necessarily have an existing scope that matches exactly the scope of the mutual exclusion, i.e., the function body. For example, the monitor call can appear in the middle of an expression. Furthermore, entry-point locking requires less code generation since any useful routine is called multiple times but there is only one entry point for many call sites.
     2451\end{cfa}
     2452
     2453Both entry point and \textbf{callsite-locking} are feasible implementations.
     2454The current \CFA implementation uses entry-point locking because it requires less work when using \textbf{raii}, effectively transferring the burden of implementation to object construction/destruction.
     2455It is harder to use \textbf{raii} for call-site locking, as it does not necessarily have an existing scope that matches exactly the scope of the mutual exclusion, \ie the function body.
     2456For example, the monitor call can appear in the middle of an expression.
     2457Furthermore, entry-point locking requires less code generation since any useful routine is called multiple times but there is only one entry point for many call sites.
    19182458
    19192459% ======================================================================
     
    19232463% ======================================================================
    19242464
    1925 Figure \ref{fig:system1} shows a high-level picture if the \CFA runtime system in regards to concurrency. Each component of the picture is explained in detail in the flowing sections.
     2465Figure \ref{fig:system1} shows a high-level picture if the \CFA runtime system in regards to concurrency.
     2466Each component of the picture is explained in detail in the flowing sections.
    19262467
    19272468\begin{figure}
     
    19342475
    19352476\subsection{Processors}
    1936 Parallelism in \CFA is built around using processors to specify how much parallelism is desired. \CFA processors are object wrappers around kernel threads, specifically \texttt{pthread}s in the current implementation of \CFA. Indeed, any parallelism must go through operating-system libraries. However, \textbf{uthread} are still the main source of concurrency, processors are simply the underlying source of parallelism. Indeed, processor \textbf{kthread} simply fetch a \textbf{uthread} from the scheduler and run it; they are effectively executers for user-threads. The main benefit of this approach is that it offers a well-defined boundary between kernel code and user code, for example, kernel thread quiescing, scheduling and interrupt handling. Processors internally use coroutines to take advantage of the existing context-switching semantics.
     2477Parallelism in \CFA is built around using processors to specify how much parallelism is desired. \CFA processors are object wrappers around kernel threads, specifically @pthread@s in the current implementation of \CFA.
     2478Indeed, any parallelism must go through operating-system libraries.
     2479However, \textbf{uthread} are still the main source of concurrency, processors are simply the underlying source of parallelism.
     2480Indeed, processor \textbf{kthread} simply fetch a \textbf{uthread} from the scheduler and run it; they are effectively executers for user-threads.
     2481The main benefit of this approach is that it offers a well-defined boundary between kernel code and user code, for example, kernel thread quiescing, scheduling and interrupt handling.
     2482Processors internally use coroutines to take advantage of the existing context-switching semantics.
    19372483
    19382484\subsection{Stack Management}
    1939 One of the challenges of this system is to reduce the footprint as much as possible. Specifically, all \texttt{pthread}s created also have a stack created with them, which should be used as much as possible. Normally, coroutines also create their own stack to run on, however, in the case of the coroutines used for processors, these coroutines run directly on the \textbf{kthread} stack, effectively stealing the processor stack. The exception to this rule is the Main Processor, i.e., the initial \textbf{kthread} that is given to any program. In order to respect C user expectations, the stack of the initial kernel thread, the main stack of the program, is used by the main user thread rather than the main processor, which can grow very large.
     2485One of the challenges of this system is to reduce the footprint as much as possible.
     2486Specifically, all @pthread@s created also have a stack created with them, which should be used as much as possible.
     2487Normally, coroutines also create their own stack to run on, however, in the case of the coroutines used for processors, these coroutines run directly on the \textbf{kthread} stack, effectively stealing the processor stack.
     2488The exception to this rule is the Main Processor, \ie the initial \textbf{kthread} that is given to any program.
     2489In order to respect C user expectations, the stack of the initial kernel thread, the main stack of the program, is used by the main user thread rather than the main processor, which can grow very large.
    19402490
    19412491\subsection{Context Switching}
    1942 As mentioned in section \ref{coroutine}, coroutines are a stepping stone for implementing threading, because they share the same mechanism for context-switching between different stacks. To improve performance and simplicity, context-switching is implemented using the following assumption: all context-switches happen inside a specific function call. This assumption means that the context-switch only has to copy the callee-saved registers onto the stack and then switch the stack registers with the ones of the target coroutine/thread. Note that the instruction pointer can be left untouched since the context-switch is always inside the same function. Threads, however, do not context-switch between each other directly. They context-switch to the scheduler. This method is called a 2-step context-switch and has the advantage of having a clear distinction between user code and the kernel where scheduling and other system operations happen. Obviously, this doubles the context-switch cost because threads must context-switch to an intermediate stack. The alternative 1-step context-switch uses the stack of the ``from'' thread to schedule and then context-switches directly to the ``to'' thread. However, the performance of the 2-step context-switch is still superior to a \code{pthread_yield} (see section \ref{results}). Additionally, for users in need for optimal performance, it is important to note that having a 2-step context-switch as the default does not prevent \CFA from offering a 1-step context-switch (akin to the Microsoft \code{SwitchToFiber}~\cite{switchToWindows} routine). This option is not currently present in \CFA, but the changes required to add it are strictly additive.
     2492As mentioned in section \ref{coroutine}, coroutines are a stepping stone for implementing threading, because they share the same mechanism for context-switching between different stacks.
     2493To improve performance and simplicity, context-switching is implemented using the following assumption: all context-switches happen inside a specific function call.
     2494This assumption means that the context-switch only has to copy the callee-saved registers onto the stack and then switch the stack registers with the ones of the target coroutine/thread.
     2495Note that the instruction pointer can be left untouched since the context-switch is always inside the same function.
     2496Threads, however, do not context-switch between each other directly.
     2497They context-switch to the scheduler.
     2498This method is called a 2-step context-switch and has the advantage of having a clear distinction between user code and the kernel where scheduling and other system operations happen.
     2499Obviously, this doubles the context-switch cost because threads must context-switch to an intermediate stack.
     2500The alternative 1-step context-switch uses the stack of the ``from'' thread to schedule and then context-switches directly to the ``to'' thread.
     2501However, the performance of the 2-step context-switch is still superior to a @pthread_yield@ (see section \ref{results}).
     2502Additionally, for users in need for optimal performance, it is important to note that having a 2-step context-switch as the default does not prevent \CFA from offering a 1-step context-switch (akin to the Microsoft @SwitchToFiber@~\cite{switchToWindows} routine).
     2503This option is not currently present in \CFA, but the changes required to add it are strictly additive.
    19432504
    19442505\subsection{Preemption} \label{preemption}
    1945 Finally, an important aspect for any complete threading system is preemption. As mentioned in section \ref{basics}, preemption introduces an extra degree of uncertainty, which enables users to have multiple threads interleave transparently, rather than having to cooperate among threads for proper scheduling and CPU distribution. Indeed, preemption is desirable because it adds a degree of isolation among threads. In a fully cooperative system, any thread that runs a long loop can starve other threads, while in a preemptive system, starvation can still occur but it does not rely on every thread having to yield or block on a regular basis, which reduces significantly a programmer burden. Obviously, preemption is not optimal for every workload. However any preemptive system can become a cooperative system by making the time slices extremely large. Therefore, \CFA uses a preemptive threading system.
    1946 
    1947 Preemption in \CFA\footnote{Note that the implementation of preemption is strongly tied with the underlying threading system. For this reason, only the Linux implementation is cover, \CFA does not run on Windows at the time of writting} is based on kernel timers, which are used to run a discrete-event simulation. Every processor keeps track of the current time and registers an expiration time with the preemption system. When the preemption system receives a change in preemption, it inserts the time in a sorted order and sets a kernel timer for the closest one, effectively stepping through preemption events on each signal sent by the timer. These timers use the Linux signal {\tt SIGALRM}, which is delivered to the process rather than the kernel-thread. This results in an implementation problem, because when delivering signals to a process, the kernel can deliver the signal to any kernel thread for which the signal is not blocked, i.e.:
     2506Finally, an important aspect for any complete threading system is preemption.
     2507As mentioned in section \ref{basics}, preemption introduces an extra degree of uncertainty, which enables users to have multiple threads interleave transparently, rather than having to cooperate among threads for proper scheduling and CPU distribution.
     2508Indeed, preemption is desirable because it adds a degree of isolation among threads.
     2509In a fully cooperative system, any thread that runs a long loop can starve other threads, while in a preemptive system, starvation can still occur but it does not rely on every thread having to yield or block on a regular basis, which reduces significantly a programmer burden.
     2510Obviously, preemption is not optimal for every workload.
     2511However any preemptive system can become a cooperative system by making the time slices extremely large.
     2512Therefore, \CFA uses a preemptive threading system.
     2513
     2514Preemption in \CFA\footnote{Note that the implementation of preemption is strongly tied with the underlying threading system.
     2515For this reason, only the Linux implementation is cover, \CFA does not run on Windows at the time of writting} is based on kernel timers, which are used to run a discrete-event simulation.
     2516Every processor keeps track of the current time and registers an expiration time with the preemption system.
     2517When the preemption system receives a change in preemption, it inserts the time in a sorted order and sets a kernel timer for the closest one, effectively stepping through preemption events on each signal sent by the timer.
     2518These timers use the Linux signal {\tt SIGALRM}, which is delivered to the process rather than the kernel-thread.
     2519This results in an implementation problem, because when delivering signals to a process, the kernel can deliver the signal to any kernel thread for which the signal is not blocked, \ie:
    19482520\begin{quote}
    1949 A process-directed signal may be delivered to any one of the threads that does not currently have the signal blocked. If more than one of the threads has the signal unblocked, then the kernel chooses an arbitrary thread to which to deliver the signal.
     2521A process-directed signal may be delivered to any one of the threads that does not currently have the signal blocked.
     2522If more than one of the threads has the signal unblocked, then the kernel chooses an arbitrary thread to which to deliver the signal.
    19502523SIGNAL(7) - Linux Programmer's Manual
    19512524\end{quote}
    19522525For the sake of simplicity, and in order to prevent the case of having two threads receiving alarms simultaneously, \CFA programs block the {\tt SIGALRM} signal on every kernel thread except one.
    19532526
    1954 Now because of how involuntary context-switches are handled, the kernel thread handling {\tt SIGALRM} cannot also be a processor thread. Hence, involuntary context-switching is done by sending signal {\tt SIGUSR1} to the corresponding proces\-sor and having the thread yield from inside the signal handler. This approach effectively context-switches away from the signal handler back to the kernel and the signal handler frame is eventually unwound when the thread is scheduled again. As a result, a signal handler can start on one kernel thread and terminate on a second kernel thread (but the same user thread). It is important to note that signal handlers save and restore signal masks because user-thread migration can cause a signal mask to migrate from one kernel thread to another. This behaviour is only a problem if all kernel threads, among which a user thread can migrate, differ in terms of signal masks\footnote{Sadly, official POSIX documentation is silent on what distinguishes ``async-signal-safe'' functions from other functions.}. However, since the kernel thread handling preemption requires a different signal mask, executing user threads on the kernel-alarm thread can cause deadlocks. For this reason, the alarm thread is in a tight loop around a system call to \code{sigwaitinfo}, requiring very little CPU time for preemption. One final detail about the alarm thread is how to wake it when additional communication is required (e.g., on thread termination). This unblocking is also done using {\tt SIGALRM}, but sent through the \code{pthread_sigqueue}. Indeed, \code{sigwait} can differentiate signals sent from \code{pthread_sigqueue} from signals sent from alarms or the kernel.
     2527Now because of how involuntary context-switches are handled, the kernel thread handling {\tt SIGALRM} cannot also be a processor thread.
     2528Hence, involuntary context-switching is done by sending signal {\tt SIGUSR1} to the corresponding proces\-sor and having the thread yield from inside the signal handler.
     2529This approach effectively context-switches away from the signal handler back to the kernel and the signal handler frame is eventually unwound when the thread is scheduled again.
     2530As a result, a signal handler can start on one kernel thread and terminate on a second kernel thread (but the same user thread).
     2531It is important to note that signal handlers save and restore signal masks because user-thread migration can cause a signal mask to migrate from one kernel thread to another.
     2532This behaviour is only a problem if all kernel threads, among which a user thread can migrate, differ in terms of signal masks\footnote{Sadly, official POSIX documentation is silent on what distinguishes ``async-signal-safe'' functions from other functions.}.
     2533However, since the kernel thread handling preemption requires a different signal mask, executing user threads on the kernel-alarm thread can cause deadlocks.
     2534For this reason, the alarm thread is in a tight loop around a system call to @sigwaitinfo@, requiring very little CPU time for preemption.
     2535One final detail about the alarm thread is how to wake it when additional communication is required (\eg on thread termination).
     2536This unblocking is also done using {\tt SIGALRM}, but sent through the @pthread_sigqueue@.
     2537Indeed, @sigwait@ can differentiate signals sent from @pthread_sigqueue@ from signals sent from alarms or the kernel.
    19552538
    19562539\subsection{Scheduler}
    1957 Finally, an aspect that was not mentioned yet is the scheduling algorithm. Currently, the \CFA scheduler uses a single ready queue for all processors, which is the simplest approach to scheduling. Further discussion on scheduling is present in section \ref{futur:sched}.
     2540Finally, an aspect that was not mentioned yet is the scheduling algorithm.
     2541Currently, the \CFA scheduler uses a single ready queue for all processors, which is the simplest approach to scheduling.
     2542Further discussion on scheduling is present in section \ref{futur:sched}.
    19582543
    19592544% ======================================================================
     
    19642549The following figure is the traditional illustration of a monitor (repeated from page~\pageref{fig:ClassicalMonitor} for convenience):
    19652550
    1966 \begin{figure}[H]
     2551\begin{figure}
    19672552\begin{center}
    19682553{\resizebox{0.4\textwidth}{!}{\input{monitor}}}
     
    19712556\end{figure}
    19722557
    1973 This picture has several components, the two most important being the entry queue and the AS-stack. The entry queue is an (almost) FIFO list where threads waiting to enter are parked, while the acceptor/signaller (AS) stack is a FILO list used for threads that have been signalled or otherwise marked as running next.
    1974 
    1975 For \CFA, this picture does not have support for blocking multiple monitors on a single condition. To support \textbf{bulk-acq} two changes to this picture are required. First, it is no longer helpful to attach the condition to \emph{a single} monitor. Secondly, the thread waiting on the condition has to be separated across multiple monitors, seen in figure \ref{fig:monitor_cfa}.
    1976 
    1977 \begin{figure}[H]
     2558This picture has several components, the two most important being the entry queue and the AS-stack.
     2559The entry queue is an (almost) FIFO list where threads waiting to enter are parked, while the acceptor/signaller (AS) stack is a FILO list used for threads that have been signalled or otherwise marked as running next.
     2560
     2561For \CFA, this picture does not have support for blocking multiple monitors on a single condition.
     2562To support \textbf{bulk-acq} two changes to this picture are required.
     2563First, it is no longer helpful to attach the condition to \emph{a single} monitor.
     2564Secondly, the thread waiting on the condition has to be separated across multiple monitors, seen in figure \ref{fig:monitor_cfa}.
     2565
     2566\begin{figure}
    19782567\begin{center}
    19792568{\resizebox{0.8\textwidth}{!}{\input{int_monitor}}}
     
    19832572\end{figure}
    19842573
    1985 This picture and the proper entry and leave algorithms (see listing \ref{lst:entry2}) is the fundamental implementation of internal scheduling. Note that when a thread is moved from the condition to the AS-stack, it is conceptually split into N pieces, where N is the number of monitors specified in the parameter list. The thread is woken up when all the pieces have popped from the AS-stacks and made active. In this picture, the threads are split into halves but this is only because there are two monitors. For a specific signalling operation every monitor needs a piece of thread on its AS-stack.
    1986 
    1987 \begin{figure}[b]
     2574This picture and the proper entry and leave algorithms (see listing \ref{f:entry2}) is the fundamental implementation of internal scheduling.
     2575Note that when a thread is moved from the condition to the AS-stack, it is conceptually split into N pieces, where N is the number of monitors specified in the parameter list.
     2576The thread is woken up when all the pieces have popped from the AS-stacks and made active.
     2577In this picture, the threads are split into halves but this is only because there are two monitors.
     2578For a specific signalling operation every monitor needs a piece of thread on its AS-stack.
     2579
     2580\begin{figure}
    19882581\begin{multicols}{2}
    19892582Entry
    1990 \begin{pseudo}
     2583\begin{cfa}
    19912584if monitor is free
    19922585        enter
     
    19972590increment recursion
    19982591
    1999 \end{pseudo}
     2592\end{cfa}
    20002593\columnbreak
    20012594Exit
    2002 \begin{pseudo}
     2595\begin{cfa}
    20032596decrement recursion
    20042597if recursion == 0
     
    20102603        if entry queue not empty
    20112604                wake-up thread
    2012 \end{pseudo}
     2605\end{cfa}
    20132606\end{multicols}
    2014 \begin{pseudo}[caption={Entry and exit routine for monitors with internal scheduling},label={lst:entry2}]
    2015 \end{pseudo}
     2607\begin{cfa}[caption={Entry and exit routine for monitors with internal scheduling},label={f:entry2}]
     2608\end{cfa}
    20162609\end{figure}
    20172610
    2018 The solution discussed in \ref{intsched} can be seen in the exit routine of listing \ref{lst:entry2}. Basically, the solution boils down to having a separate data structure for the condition queue and the AS-stack, and unconditionally transferring ownership of the monitors but only unblocking the thread when the last monitor has transferred ownership. This solution is deadlock safe as well as preventing any potential barging. The data structures used for the AS-stack are reused extensively for external scheduling, but in the case of internal scheduling, the data is allocated using variable-length arrays on the call stack of the \code{wait} and \code{signal_block} routines.
    2019 
    2020 \begin{figure}[H]
     2611The solution discussed in \ref{intsched} can be seen in the exit routine of listing \ref{f:entry2}.
     2612Basically, the solution boils down to having a separate data structure for the condition queue and the AS-stack, and unconditionally transferring ownership of the monitors but only unblocking the thread when the last monitor has transferred ownership.
     2613This solution is deadlock safe as well as preventing any potential barging.
     2614The data structures used for the AS-stack are reused extensively for external scheduling, but in the case of internal scheduling, the data is allocated using variable-length arrays on the call stack of the @wait@ and @signal_block@ routines.
     2615
     2616\begin{figure}
    20212617\begin{center}
    20222618{\resizebox{0.8\textwidth}{!}{\input{monitor_structs.pstex_t}}}
     
    20262622\end{figure}
    20272623
    2028 Figure \ref{fig:structs} shows a high-level representation of these data structures. The main idea behind them is that, a thread cannot contain an arbitrary number of intrusive ``next'' pointers for linking onto monitors. The \code{condition node} is the data structure that is queued onto a condition variable and, when signalled, the condition queue is popped and each \code{condition criterion} is moved to the AS-stack. Once all the criteria have been popped from their respective AS-stacks, the thread is woken up, which is what is shown in listing \ref{lst:entry2}.
     2624Figure \ref{fig:structs} shows a high-level representation of these data structures.
     2625The main idea behind them is that, a thread cannot contain an arbitrary number of intrusive ``next'' pointers for linking onto monitors.
     2626The @condition node@ is the data structure that is queued onto a condition variable and, when signalled, the condition queue is popped and each @condition criterion@ is moved to the AS-stack.
     2627Once all the criteria have been popped from their respective AS-stacks, the thread is woken up, which is what is shown in listing \ref{f:entry2}.
    20292628
    20302629% ======================================================================
     
    20332632% ======================================================================
    20342633% ======================================================================
    2035 Similarly to internal scheduling, external scheduling for multiple monitors relies on the idea that waiting-thread queues are no longer specific to a single monitor, as mentioned in section \ref{extsched}. For internal scheduling, these queues are part of condition variables, which are still unique for a given scheduling operation (i.e., no signal statement uses multiple conditions). However, in the case of external scheduling, there is no equivalent object which is associated with \code{waitfor} statements. This absence means the queues holding the waiting threads must be stored inside at least one of the monitors that is acquired. These monitors being the only objects that have sufficient lifetime and are available on both sides of the \code{waitfor} statement. This requires an algorithm to choose which monitor holds the relevant queue. It is also important that said algorithm be independent of the order in which users list parameters. The proposed algorithm is to fall back on monitor lock ordering (sorting by address) and specify that the monitor that is acquired first is the one with the relevant waiting queue. This assumes that the lock acquiring order is static for the lifetime of all concerned objects but that is a reasonable constraint.
     2634Similarly to internal scheduling, external scheduling for multiple monitors relies on the idea that waiting-thread queues are no longer specific to a single monitor, as mentioned in section \ref{extsched}.
     2635For internal scheduling, these queues are part of condition variables, which are still unique for a given scheduling operation (\ie no signal statement uses multiple conditions).
     2636However, in the case of external scheduling, there is no equivalent object which is associated with @waitfor@ statements.
     2637This absence means the queues holding the waiting threads must be stored inside at least one of the monitors that is acquired.
     2638These monitors being the only objects that have sufficient lifetime and are available on both sides of the @waitfor@ statement.
     2639This requires an algorithm to choose which monitor holds the relevant queue.
     2640It is also important that said algorithm be independent of the order in which users list parameters.
     2641The proposed algorithm is to fall back on monitor lock ordering (sorting by address) and specify that the monitor that is acquired first is the one with the relevant waiting queue.
     2642This assumes that the lock acquiring order is static for the lifetime of all concerned objects but that is a reasonable constraint.
    20362643
    20372644This algorithm choice has two consequences:
    20382645\begin{itemize}
    2039         \item The queue of the monitor with the lowest address is no longer a true FIFO queue because threads can be moved to the front of the queue. These queues need to contain a set of monitors for each of the waiting threads. Therefore, another thread whose set contains the same lowest address monitor but different lower priority monitors may arrive first but enter the critical section after a thread with the correct pairing.
    2040         \item The queue of the lowest priority monitor is both required and potentially unused. Indeed, since it is not known at compile time which monitor is the monitor which has the lowest address, every monitor needs to have the correct queues even though it is possible that some queues go unused for the entire duration of the program, for example if a monitor is only used in a specific pair.
     2646        \item The queue of the monitor with the lowest address is no longer a true FIFO queue because threads can be moved to the front of the queue.
     2647These queues need to contain a set of monitors for each of the waiting threads.
     2648Therefore, another thread whose set contains the same lowest address monitor but different lower priority monitors may arrive first but enter the critical section after a thread with the correct pairing.
     2649        \item The queue of the lowest priority monitor is both required and potentially unused.
     2650Indeed, since it is not known at compile time which monitor is the monitor which has the lowest address, every monitor needs to have the correct queues even though it is possible that some queues go unused for the entire duration of the program, for example if a monitor is only used in a specific pair.
    20412651\end{itemize}
    20422652Therefore, the following modifications need to be made to support external scheduling:
    20432653\begin{itemize}
    2044         \item The threads waiting on the entry queue need to keep track of which routine they are trying to enter, and using which set of monitors. The \code{mutex} routine already has all the required information on its stack, so the thread only needs to keep a pointer to that information.
    2045         \item The monitors need to keep a mask of acceptable routines. This mask contains for each acceptable routine, a routine pointer and an array of monitors to go with it. It also needs storage to keep track of which routine was accepted. Since this information is not specific to any monitor, the monitors actually contain a pointer to an integer on the stack of the waiting thread. Note that if a thread has acquired two monitors but executes a \code{waitfor} with only one monitor as a parameter, setting the mask of acceptable routines to both monitors will not cause any problems since the extra monitor will not change ownership regardless. This becomes relevant when \code{when} clauses affect the number of monitors passed to a \code{waitfor} statement.
    2046         \item The entry/exit routines need to be updated as shown in listing \ref{lst:entry3}.
     2654        \item The threads waiting on the entry queue need to keep track of which routine they are trying to enter, and using which set of monitors.
     2655The @mutex@ routine already has all the required information on its stack, so the thread only needs to keep a pointer to that information.
     2656        \item The monitors need to keep a mask of acceptable routines.
     2657This mask contains for each acceptable routine, a routine pointer and an array of monitors to go with it.
     2658It also needs storage to keep track of which routine was accepted.
     2659Since this information is not specific to any monitor, the monitors actually contain a pointer to an integer on the stack of the waiting thread.
     2660Note that if a thread has acquired two monitors but executes a @waitfor@ with only one monitor as a parameter, setting the mask of acceptable routines to both monitors will not cause any problems since the extra monitor will not change ownership regardless.
     2661This becomes relevant when @when@ clauses affect the number of monitors passed to a @waitfor@ statement.
     2662        \item The entry/exit routines need to be updated as shown in listing \ref{f:entry3}.
    20472663\end{itemize}
    20482664
    20492665\subsection{External Scheduling - Destructors}
    2050 Finally, to support the ordering inversion of destructors, the code generation needs to be modified to use a special entry routine. This routine is needed because of the storage requirements of the call order inversion. Indeed, when waiting for the destructors, storage is needed for the waiting context and the lifetime of said storage needs to outlive the waiting operation it is needed for. For regular \code{waitfor} statements, the call stack of the routine itself matches this requirement but it is no longer the case when waiting for the destructor since it is pushed on to the AS-stack for later. The \code{waitfor} semantics can then be adjusted correspondingly, as seen in listing \ref{lst:entry-dtor}
     2666Finally, to support the ordering inversion of destructors, the code generation needs to be modified to use a special entry routine.
     2667This routine is needed because of the storage requirements of the call order inversion.
     2668Indeed, when waiting for the destructors, storage is needed for the waiting context and the lifetime of said storage needs to outlive the waiting operation it is needed for.
     2669For regular @waitfor@ statements, the call stack of the routine itself matches this requirement but it is no longer the case when waiting for the destructor since it is pushed on to the AS-stack for later.
     2670The @waitfor@ semantics can then be adjusted correspondingly, as seen in listing \ref{f:entry-dtor}
    20512671
    20522672\begin{figure}
    20532673\begin{multicols}{2}
    20542674Entry
    2055 \begin{pseudo}
     2675\begin{cfa}
    20562676if monitor is free
    20572677        enter
     
    20642684        block
    20652685increment recursion
    2066 \end{pseudo}
     2686\end{cfa}
    20672687\columnbreak
    20682688Exit
    2069 \begin{pseudo}
     2689\begin{cfa}
    20702690decrement recursion
    20712691if recursion == 0
     
    20802700                wake-up thread
    20812701        endif
    2082 \end{pseudo}
     2702\end{cfa}
    20832703\end{multicols}
    2084 \begin{pseudo}[caption={Entry and exit routine for monitors with internal scheduling and external scheduling},label={lst:entry3}]
    2085 \end{pseudo}
     2704\begin{cfa}[caption={Entry and exit routine for monitors with internal scheduling and external scheduling},label={f:entry3}]
     2705\end{cfa}
    20862706\end{figure}
    20872707
     
    20892709\begin{multicols}{2}
    20902710Destructor Entry
    2091 \begin{pseudo}
     2711\begin{cfa}
    20922712if monitor is free
    20932713        enter
     
    21032723        wait
    21042724increment recursion
    2105 \end{pseudo}
     2725\end{cfa}
    21062726\columnbreak
    21072727Waitfor
    2108 \begin{pseudo}
     2728\begin{cfa}
    21092729if matching thread is already there
    21102730        if found destructor
     
    21262746block
    21272747return
    2128 \end{pseudo}
     2748\end{cfa}
    21292749\end{multicols}
    2130 \begin{pseudo}[caption={Pseudo code for the \code{waitfor} routine and the \code{mutex} entry routine for destructors},label={lst:entry-dtor}]
    2131 \end{pseudo}
     2750\begin{cfa}[caption={Pseudo code for the \protect\lstinline|waitfor| routine and the \protect\lstinline|mutex| entry routine for destructors},label={f:entry-dtor}]
     2751\end{cfa}
    21322752\end{figure}
    21332753
     
    21412761
    21422762\section{Threads As Monitors}
    2143 As it was subtly alluded in section \ref{threads}, \code{thread}s in \CFA are in fact monitors, which means that all monitor features are available when using threads. For example, here is a very simple two thread pipeline that could be used for a simulator of a game engine:
    2144 \begin{figure}[H]
    2145 \begin{cfacode}[caption={Toy simulator using \code{thread}s and \code{monitor}s.},label={lst:engine-v1}]
     2763As it was subtly alluded in section \ref{threads}, @thread@s in \CFA are in fact monitors, which means that all monitor features are available when using threads.
     2764For example, here is a very simple two thread pipeline that could be used for a simulator of a game engine:
     2765\begin{figure}
     2766\begin{cfa}[caption={Toy simulator using \protect\lstinline|thread|s and \protect\lstinline|monitor|s.},label={f:engine-v1}]
    21462767// Visualization declaration
    21472768thread Renderer {} renderer;
     
    21702791        }
    21712792}
    2172 \end{cfacode}
     2793\end{cfa}
    21732794\end{figure}
    2174 One of the obvious complaints of the previous code snippet (other than its toy-like simplicity) is that it does not handle exit conditions and just goes on forever. Luckily, the monitor semantics can also be used to clearly enforce a shutdown order in a concise manner:
    2175 \begin{figure}[H]
    2176 \begin{cfacode}[caption={Same toy simulator with proper termination condition.},label={lst:engine-v2}]
     2795One of the obvious complaints of the previous code snippet (other than its toy-like simplicity) is that it does not handle exit conditions and just goes on forever.
     2796Luckily, the monitor semantics can also be used to clearly enforce a shutdown order in a concise manner:
     2797\begin{figure}
     2798\begin{cfa}[caption={Same toy simulator with proper termination condition.},label={f:engine-v2}]
    21772799// Visualization declaration
    21782800thread Renderer {} renderer;
     
    22122834// Call destructor for simulator once simulator finishes
    22132835// Call destructor for renderer to signify shutdown
    2214 \end{cfacode}
     2836\end{cfa}
    22152837\end{figure}
    22162838
    22172839\section{Fibers \& Threads}
    2218 As mentioned in section \ref{preemption}, \CFA uses preemptive threads by default but can use fibers on demand. Currently, using fibers is done by adding the following line of code to the program~:
    2219 \begin{cfacode}
     2840As mentioned in section \ref{preemption}, \CFA uses preemptive threads by default but can use fibers on demand.
     2841Currently, using fibers is done by adding the following line of code to the program~:
     2842\begin{cfa}
    22202843unsigned int default_preemption() {
    22212844        return 0;
    22222845}
    2223 \end{cfacode}
    2224 This function is called by the kernel to fetch the default preemption rate, where 0 signifies an infinite time-slice, i.e., no preemption. However, once clusters are fully implemented, it will be possible to create fibers and \textbf{uthread} in the same system, as in listing \ref{lst:fiber-uthread}
     2846\end{cfa}
     2847This function is called by the kernel to fetch the default preemption rate, where 0 signifies an infinite time-slice, \ie no preemption.
     2848However, once clusters are fully implemented, it will be possible to create fibers and \textbf{uthread} in the same system, as in listing \ref{f:fiber-uthread}
    22252849\begin{figure}
    2226 \begin{cfacode}[caption={Using fibers and \textbf{uthread} side-by-side in \CFA},label={lst:fiber-uthread}]
    2227 //Cluster forward declaration
     2850\lstset{language=CFA,deletedelim=**[is][]{`}{`}}
     2851\begin{cfa}[caption={Using fibers and \textbf{uthread} side-by-side in \CFA},label={f:fiber-uthread}]
     2852// Cluster forward declaration
    22282853struct cluster;
    22292854
    2230 //Processor forward declaration
     2855// Processor forward declaration
    22312856struct processor;
    22322857
    2233 //Construct clusters with a preemption rate
     2858// Construct clusters with a preemption rate
    22342859void ?{}(cluster& this, unsigned int rate);
    2235 //Construct processor and add it to cluster
     2860// Construct processor and add it to cluster
    22362861void ?{}(processor& this, cluster& cluster);
    2237 //Construct thread and schedule it on cluster
     2862// Construct thread and schedule it on cluster
    22382863void ?{}(thread& this, cluster& cluster);
    22392864
    2240 //Declare two clusters
    2241 cluster thread_cluster = { 10`ms };                     //Preempt every 10 ms
    2242 cluster fibers_cluster = { 0 };                         //Never preempt
    2243 
    2244 //Construct 4 processors
     2865// Declare two clusters
     2866cluster thread_cluster = { 10`ms };                     // Preempt every 10 ms
     2867cluster fibers_cluster = { 0 };                         // Never preempt
     2868
     2869// Construct 4 processors
    22452870processor processors[4] = {
    22462871        //2 for the thread cluster
     
    22522877};
    22532878
    2254 //Declares thread
     2879// Declares thread
    22552880thread UThread {};
    22562881void ?{}(UThread& this) {
    2257         //Construct underlying thread to automatically
    2258         //be scheduled on the thread cluster
     2882        // Construct underlying thread to automatically
     2883        // be scheduled on the thread cluster
    22592884        (this){ thread_cluster }
    22602885}
     
    22622887void main(UThread & this);
    22632888
    2264 //Declares fibers
     2889// Declares fibers
    22652890thread Fiber {};
    22662891void ?{}(Fiber& this) {
    2267         //Construct underlying thread to automatically
    2268         //be scheduled on the fiber cluster
     2892        // Construct underlying thread to automatically
     2893        // be scheduled on the fiber cluster
    22692894        (this.__thread){ fibers_cluster }
    22702895}
    22712896
    22722897void main(Fiber & this);
    2273 \end{cfacode}
     2898\end{cfa}
    22742899\end{figure}
    22752900
     
    22812906% ======================================================================
    22822907\section{Machine Setup}
    2283 Table \ref{tab:machine} shows the characteristics of the machine used to run the benchmarks. All tests were made on this machine.
    2284 \begin{table}[H]
     2908Table \ref{tab:machine} shows the characteristics of the machine used to run the benchmarks.
     2909All tests were made on this machine.
     2910\begin{table}
    22852911\begin{center}
    22862912\begin{tabular}{| l | r | l | r |}
     
    23142940
    23152941\section{Micro Benchmarks}
    2316 All benchmarks are run using the same harness to produce the results, seen as the \code{BENCH()} macro in the following examples. This macro uses the following logic to benchmark the code:
    2317 \begin{pseudo}
     2942All benchmarks are run using the same harness to produce the results, seen as the @BENCH()@ macro in the following examples.
     2943This macro uses the following logic to benchmark the code:
     2944\begin{cfa}
    23182945#define BENCH(run, result) \
    23192946        before = gettime(); \
     
    23212948        after  = gettime(); \
    23222949        result = (after - before) / N;
    2323 \end{pseudo}
    2324 The method used to get time is \code{clock_gettime(CLOCK_THREAD_CPUTIME_ID);}. Each benchmark is using many iterations of a simple call to measure the cost of the call. The specific number of iterations depends on the specific benchmark.
     2950\end{cfa}
     2951The method used to get time is @clock_gettime(CLOCK_THREAD_CPUTIME_ID);@.
     2952Each benchmark is using many iterations of a simple call to measure the cost of the call.
     2953The specific number of iterations depends on the specific benchmark.
    23252954
    23262955\subsection{Context-Switching}
    2327 The first interesting benchmark is to measure how long context-switches take. The simplest approach to do this is to yield on a thread, which executes a 2-step context switch. Yielding causes the thread to context-switch to the scheduler and back, more precisely: from the \textbf{uthread} to the \textbf{kthread} then from the \textbf{kthread} back to the same \textbf{uthread} (or a different one in the general case). In order to make the comparison fair, coroutines also execute a 2-step context-switch by resuming another coroutine which does nothing but suspending in a tight loop, which is a resume/suspend cycle instead of a yield. Listing \ref{lst:ctx-switch} shows the code for coroutines and threads with the results in table \ref{tab:ctx-switch}. All omitted tests are functionally identical to one of these tests. The difference between coroutines and threads can be attributed to the cost of scheduling.
     2956The first interesting benchmark is to measure how long context-switches take.
     2957The simplest approach to do this is to yield on a thread, which executes a 2-step context switch.
     2958Yielding causes the thread to context-switch to the scheduler and back, more precisely: from the \textbf{uthread} to the \textbf{kthread} then from the \textbf{kthread} back to the same \textbf{uthread} (or a different one in the general case).
     2959In order to make the comparison fair, coroutines also execute a 2-step context-switch by resuming another coroutine which does nothing but suspending in a tight loop, which is a resume/suspend cycle instead of a yield.
     2960Figure~\ref{f:ctx-switch} shows the code for coroutines and threads with the results in table \ref{tab:ctx-switch}.
     2961All omitted tests are functionally identical to one of these tests.
     2962The difference between coroutines and threads can be attributed to the cost of scheduling.
    23282963\begin{figure}
    23292964\begin{multicols}{2}
    23302965\CFA Coroutines
    2331 \begin{cfacode}
     2966\begin{cfa}
    23322967coroutine GreatSuspender {};
    23332968void main(GreatSuspender& this) {
     
    23452980        printf("%llu\n", result);
    23462981}
    2347 \end{cfacode}
     2982\end{cfa}
    23482983\columnbreak
    23492984\CFA Threads
    2350 \begin{cfacode}
     2985\begin{cfa}
    23512986
    23522987
     
    23642999        printf("%llu\n", result);
    23653000}
    2366 \end{cfacode}
     3001\end{cfa}
    23673002\end{multicols}
    2368 \begin{cfacode}[caption={\CFA benchmark code used to measure context-switches for coroutines and threads.},label={lst:ctx-switch}]
    2369 \end{cfacode}
     3003\begin{cfa}[caption={\CFA benchmark code used to measure context-switches for coroutines and threads.},label={f:ctx-switch}]
     3004\end{cfa}
    23703005\end{figure}
    23713006
     
    23863021\end{tabular}
    23873022\end{center}
    2388 \caption{Context Switch comparison. All numbers are in nanoseconds(\si{\nano\second})}
     3023\caption{Context Switch comparison.
     3024All numbers are in nanoseconds(\si{\nano\second})}
    23893025\label{tab:ctx-switch}
    23903026\end{table}
    23913027
    23923028\subsection{Mutual-Exclusion}
    2393 The next interesting benchmark is to measure the overhead to enter/leave a critical-section. For monitors, the simplest approach is to measure how long it takes to enter and leave a monitor routine. Listing \ref{lst:mutex} shows the code for \CFA. To put the results in context, the cost of entering a non-inline function and the cost of acquiring and releasing a \code{pthread_mutex} lock is also measured. The results can be shown in table \ref{tab:mutex}.
     3029The next interesting benchmark is to measure the overhead to enter/leave a critical-section.
     3030For monitors, the simplest approach is to measure how long it takes to enter and leave a monitor routine.
     3031Figure~\ref{f:mutex} shows the code for \CFA.
     3032To put the results in context, the cost of entering a non-inline function and the cost of acquiring and releasing a @pthread_mutex@ lock is also measured.
     3033The results can be shown in table \ref{tab:mutex}.
    23943034
    23953035\begin{figure}
    2396 \begin{cfacode}[caption={\CFA benchmark code used to measure mutex routines.},label={lst:mutex}]
     3036\begin{cfa}[caption={\CFA benchmark code used to measure mutex routines.},label={f:mutex}]
    23973037monitor M {};
    23983038void __attribute__((noinline)) call( M & mutex m /*, m2, m3, m4*/ ) {}
     
    24083048        printf("%llu\n", result);
    24093049}
    2410 \end{cfacode}
     3050\end{cfa}
    24113051\end{figure}
    24123052
     
    24203060FetchAdd + FetchSub                             & 26            & 26            & 0    \\
    24213061Pthreads Mutex Lock                             & 31            & 31.86 & 0.99 \\
    2422 \uC \code{monitor} member routine               & 30            & 30            & 0    \\
    2423 \CFA \code{mutex} routine, 1 argument   & 41            & 41.57 & 0.9  \\
    2424 \CFA \code{mutex} routine, 2 argument   & 76            & 76.96 & 1.57 \\
    2425 \CFA \code{mutex} routine, 4 argument   & 145           & 146.68        & 3.85 \\
     3062\uC @monitor@ member routine            & 30            & 30            & 0    \\
     3063\CFA @mutex@ routine, 1 argument        & 41            & 41.57 & 0.9  \\
     3064\CFA @mutex@ routine, 2 argument        & 76            & 76.96 & 1.57 \\
     3065\CFA @mutex@ routine, 4 argument        & 145           & 146.68        & 3.85 \\
    24263066Java synchronized routine                       & 27            & 28.57 & 2.6  \\
    24273067\hline
    24283068\end{tabular}
    24293069\end{center}
    2430 \caption{Mutex routine comparison. All numbers are in nanoseconds(\si{\nano\second})}
     3070\caption{Mutex routine comparison.
     3071All numbers are in nanoseconds(\si{\nano\second})}
    24313072\label{tab:mutex}
    24323073\end{table}
    24333074
    24343075\subsection{Internal Scheduling}
    2435 The internal-scheduling benchmark measures the cost of waiting on and signalling a condition variable. Listing \ref{lst:int-sched} shows the code for \CFA, with results table \ref{tab:int-sched}. As with all other benchmarks, all omitted tests are functionally identical to one of these tests.
     3076The internal-scheduling benchmark measures the cost of waiting on and signalling a condition variable.
     3077Figure~\ref{f:int-sched} shows the code for \CFA, with results table \ref{tab:int-sched}.
     3078As with all other benchmarks, all omitted tests are functionally identical to one of these tests.
    24363079
    24373080\begin{figure}
    2438 \begin{cfacode}[caption={Benchmark code for internal scheduling},label={lst:int-sched}]
     3081\begin{cfa}[caption={Benchmark code for internal scheduling},label={f:int-sched}]
    24393082volatile int go = 0;
    24403083condition c;
     
    24663109        return do_wait(m1);
    24673110}
    2468 \end{cfacode}
     3111\end{cfa}
    24693112\end{figure}
    24703113
     
    24763119\hline
    24773120Pthreads Condition Variable                     & 5902.5        & 6093.29       & 714.78 \\
    2478 \uC \code{signal}                                       & 322           & 323   & 3.36   \\
    2479 \CFA \code{signal}, 1 \code{monitor}    & 352.5 & 353.11        & 3.66   \\
    2480 \CFA \code{signal}, 2 \code{monitor}    & 430           & 430.29        & 8.97   \\
    2481 \CFA \code{signal}, 4 \code{monitor}    & 594.5 & 606.57        & 18.33  \\
    2482 Java \code{notify}                              & 13831.5       & 15698.21      & 4782.3 \\
     3121\uC @signal@                                    & 322           & 323   & 3.36   \\
     3122\CFA @signal@, 1 @monitor@      & 352.5 & 353.11        & 3.66   \\
     3123\CFA @signal@, 2 @monitor@      & 430           & 430.29        & 8.97   \\
     3124\CFA @signal@, 4 @monitor@      & 594.5 & 606.57        & 18.33  \\
     3125Java @notify@                           & 13831.5       & 15698.21      & 4782.3 \\
    24833126\hline
    24843127\end{tabular}
    24853128\end{center}
    2486 \caption{Internal scheduling comparison. All numbers are in nanoseconds(\si{\nano\second})}
     3129\caption{Internal scheduling comparison.
     3130All numbers are in nanoseconds(\si{\nano\second})}
    24873131\label{tab:int-sched}
    24883132\end{table}
    24893133
    24903134\subsection{External Scheduling}
    2491 The Internal scheduling benchmark measures the cost of the \code{waitfor} statement (\code{_Accept} in \uC). Listing \ref{lst:ext-sched} shows the code for \CFA, with results in table \ref{tab:ext-sched}. As with all other benchmarks, all omitted tests are functionally identical to one of these tests.
     3135The Internal scheduling benchmark measures the cost of the @waitfor@ statement (@_Accept@ in \uC).
     3136Figure~\ref{f:ext-sched} shows the code for \CFA, with results in table \ref{tab:ext-sched}.
     3137As with all other benchmarks, all omitted tests are functionally identical to one of these tests.
    24923138
    24933139\begin{figure}
    2494 \begin{cfacode}[caption={Benchmark code for external scheduling},label={lst:ext-sched}]
     3140\begin{cfa}[caption={Benchmark code for external scheduling},label={f:ext-sched}]
    24953141volatile int go = 0;
    24963142monitor M {};
     
    25213167        return do_wait(m1);
    25223168}
    2523 \end{cfacode}
     3169\end{cfa}
    25243170\end{figure}
    25253171
     
    25303176\multicolumn{1}{c |}{} & \multicolumn{1}{c |}{ Median } &\multicolumn{1}{c |}{ Average } & \multicolumn{1}{c |}{ Standard Deviation} \\
    25313177\hline
    2532 \uC \code{Accept}                                       & 350           & 350.61        & 3.11  \\
    2533 \CFA \code{waitfor}, 1 \code{monitor}   & 358.5 & 358.36        & 3.82  \\
    2534 \CFA \code{waitfor}, 2 \code{monitor}   & 422           & 426.79        & 7.95  \\
    2535 \CFA \code{waitfor}, 4 \code{monitor}   & 579.5 & 585.46        & 11.25 \\
     3178\uC @Accept@                                    & 350           & 350.61        & 3.11  \\
     3179\CFA @waitfor@, 1 @monitor@     & 358.5 & 358.36        & 3.82  \\
     3180\CFA @waitfor@, 2 @monitor@     & 422           & 426.79        & 7.95  \\
     3181\CFA @waitfor@, 4 @monitor@     & 579.5 & 585.46        & 11.25 \\
    25363182\hline
    25373183\end{tabular}
    25383184\end{center}
    2539 \caption{External scheduling comparison. All numbers are in nanoseconds(\si{\nano\second})}
     3185\caption{External scheduling comparison.
     3186All numbers are in nanoseconds(\si{\nano\second})}
    25403187\label{tab:ext-sched}
    25413188\end{table}
    25423189
     3190
    25433191\subsection{Object Creation}
    2544 Finally, the last benchmark measures the cost of creation for concurrent objects. Listing \ref{lst:creation} shows the code for \texttt{pthread}s and \CFA threads, with results shown in table \ref{tab:creation}. As with all other benchmarks, all omitted tests are functionally identical to one of these tests. The only note here is that the call stacks of \CFA coroutines are lazily created, therefore without priming the coroutine, the creation cost is very low.
     3192Finally, the last benchmark measures the cost of creation for concurrent objects.
     3193Figure~\ref{f:creation} shows the code for @pthread@s and \CFA threads, with results shown in table \ref{tab:creation}.
     3194As with all other benchmarks, all omitted tests are functionally identical to one of these tests.
     3195The only note here is that the call stacks of \CFA coroutines are lazily created, therefore without priming the coroutine, the creation cost is very low.
    25453196
    25463197\begin{figure}
    25473198\begin{center}
    2548 \texttt{pthread}
    2549 \begin{ccode}
     3199@pthread@
     3200\begin{cfa}
    25503201int main() {
    25513202        BENCH(
     
    25663217        printf("%llu\n", result);
    25673218}
    2568 \end{ccode}
     3219\end{cfa}
    25693220
    25703221
    25713222
    25723223\CFA Threads
    2573 \begin{cfacode}
     3224\begin{cfa}
    25743225int main() {
    25753226        BENCH(
     
    25813232        printf("%llu\n", result);
    25823233}
    2583 \end{cfacode}
     3234\end{cfa}
    25843235\end{center}
    2585 \begin{cfacode}[caption={Benchmark code for \texttt{pthread}s and \CFA to measure object creation},label={lst:creation}]
    2586 \end{cfacode}
     3236\caption{Benchmark code for \protect\lstinline|pthread|s and \CFA to measure object creation}
     3237\label{f:creation}
    25873238\end{figure}
    25883239
     
    26043255\end{tabular}
    26053256\end{center}
    2606 \caption{Creation comparison. All numbers are in nanoseconds(\si{\nano\second}).}
     3257\caption{Creation comparison.
     3258All numbers are in nanoseconds(\si{\nano\second}).}
    26073259\label{tab:creation}
    26083260\end{table}
     
    26113263
    26123264\section{Conclusion}
    2613 This paper has achieved a minimal concurrency \textbf{api} that is simple, efficient and usable as the basis for higher-level features. The approach presented is based on a lightweight thread-system for parallelism, which sits on top of clusters of processors. This M:N model is judged to be both more efficient and allow more flexibility for users. Furthermore, this document introduces monitors as the main concurrency tool for users. This paper also offers a novel approach allowing multiple monitors to be accessed simultaneously without running into the Nested Monitor Problem~\cite{Lister77}. It also offers a full implementation of the concurrency runtime written entirely in \CFA, effectively the largest \CFA code base to date.
     3265This paper has achieved a minimal concurrency \textbf{api} that is simple, efficient and usable as the basis for higher-level features.
     3266The approach presented is based on a lightweight thread-system for parallelism, which sits on top of clusters of processors.
     3267This M:N model is judged to be both more efficient and allow more flexibility for users.
     3268Furthermore, this document introduces monitors as the main concurrency tool for users.
     3269This paper also offers a novel approach allowing multiple monitors to be accessed simultaneously without running into the Nested Monitor Problem~\cite{Lister77}.
     3270It also offers a full implementation of the concurrency runtime written entirely in \CFA, effectively the largest \CFA code base to date.
    26143271
    26153272
     
    26213278
    26223279\subsection{Performance} \label{futur:perf}
    2623 This paper presents a first implementation of the \CFA concurrency runtime. Therefore, there is still significant work to improve performance. Many of the data structures and algorithms may change in the future to more efficient versions. For example, the number of monitors in a single \textbf{bulk-acq} is only bound by the stack size, this is probably unnecessarily generous. It may be possible that limiting the number helps increase performance. However, it is not obvious that the benefit would be significant.
     3280This paper presents a first implementation of the \CFA concurrency runtime.
     3281Therefore, there is still significant work to improve performance.
     3282Many of the data structures and algorithms may change in the future to more efficient versions.
     3283For example, the number of monitors in a single \textbf{bulk-acq} is only bound by the stack size, this is probably unnecessarily generous.
     3284It may be possible that limiting the number helps increase performance.
     3285However, it is not obvious that the benefit would be significant.
    26243286
    26253287\subsection{Flexible Scheduling} \label{futur:sched}
    2626 An important part of concurrency is scheduling. Different scheduling algorithms can affect performance (both in terms of average and variation). However, no single scheduler is optimal for all workloads and therefore there is value in being able to change the scheduler for given programs. One solution is to offer various tweaking options to users, allowing the scheduler to be adjusted to the requirements of the workload. However, in order to be truly flexible, it would be interesting to allow users to add arbitrary data and arbitrary scheduling algorithms. For example, a web server could attach Type-of-Service information to threads and have a ``ToS aware'' scheduling algorithm tailored to this specific web server. This path of flexible schedulers will be explored for \CFA.
     3288An important part of concurrency is scheduling.
     3289Different scheduling algorithms can affect performance (both in terms of average and variation).
     3290However, no single scheduler is optimal for all workloads and therefore there is value in being able to change the scheduler for given programs.
     3291One solution is to offer various tweaking options to users, allowing the scheduler to be adjusted to the requirements of the workload.
     3292However, in order to be truly flexible, it would be interesting to allow users to add arbitrary data and arbitrary scheduling algorithms.
     3293For example, a web server could attach Type-of-Service information to threads and have a ``ToS aware'' scheduling algorithm tailored to this specific web server.
     3294This path of flexible schedulers will be explored for \CFA.
    26273295
    26283296\subsection{Non-Blocking I/O} \label{futur:nbio}
    2629 While most of the parallelism tools are aimed at data parallelism and control-flow parallelism, many modern workloads are not bound on computation but on IO operations, a common case being web servers and XaaS (anything as a service). These types of workloads often require significant engineering around amortizing costs of blocking IO operations. At its core, non-blocking I/O is an operating system level feature that allows queuing IO operations (e.g., network operations) and registering for notifications instead of waiting for requests to complete. In this context, the role of the language makes Non-Blocking IO easily available and with low overhead. The current trend is to use asynchronous programming using tools like callbacks and/or futures and promises, which can be seen in frameworks like Node.js~\cite{NodeJs} for JavaScript, Spring MVC~\cite{SpringMVC} for Java and Django~\cite{Django} for Python. However, while these are valid solutions, they lead to code that is harder to read and maintain because it is much less linear.
     3297While most of the parallelism tools are aimed at data parallelism and control-flow parallelism, many modern workloads are not bound on computation but on IO operations, a common case being web servers and XaaS (anything as a service).
     3298These types of workloads often require significant engineering around amortizing costs of blocking IO operations.
     3299At its core, non-blocking I/O is an operating system level feature that allows queuing IO operations (\eg network operations) and registering for notifications instead of waiting for requests to complete.
     3300In this context, the role of the language makes Non-Blocking IO easily available and with low overhead.
     3301The current trend is to use asynchronous programming using tools like callbacks and/or futures and promises, which can be seen in frameworks like Node.js~\cite{NodeJs} for JavaScript, Spring MVC~\cite{SpringMVC} for Java and Django~\cite{Django} for Python.
     3302However, while these are valid solutions, they lead to code that is harder to read and maintain because it is much less linear.
    26303303
    26313304\subsection{Other Concurrency Tools} \label{futur:tools}
    2632 While monitors offer a flexible and powerful concurrent core for \CFA, other concurrency tools are also necessary for a complete multi-paradigm concurrency package. Examples of such tools can include simple locks and condition variables, futures and promises~\cite{promises}, executors and actors. These additional features are useful when monitors offer a level of abstraction that is inadequate for certain tasks.
     3305While monitors offer a flexible and powerful concurrent core for \CFA, other concurrency tools are also necessary for a complete multi-paradigm concurrency package.
     3306Examples of such tools can include simple locks and condition variables, futures and promises~\cite{promises}, executors and actors.
     3307These additional features are useful when monitors offer a level of abstraction that is inadequate for certain tasks.
    26333308
    26343309\subsection{Implicit Threading} \label{futur:implcit}
    2635 Simpler applications can benefit greatly from having implicit parallelism. That is, parallelism that does not rely on the user to write concurrency. This type of parallelism can be achieved both at the language level and at the library level. The canonical example of implicit parallelism is parallel for loops, which are the simplest example of a divide and conquer algorithms~\cite{uC++book}. Table \ref{lst:parfor} shows three different code examples that accomplish point-wise sums of large arrays. Note that none of these examples explicitly declare any concurrency or parallelism objects.
     3310Simpler applications can benefit greatly from having implicit parallelism.
     3311That is, parallelism that does not rely on the user to write concurrency.
     3312This type of parallelism can be achieved both at the language level and at the library level.
     3313The canonical example of implicit parallelism is parallel for loops, which are the simplest example of a divide and conquer algorithms~\cite{uC++book}.
     3314Table \ref{f:parfor} shows three different code examples that accomplish point-wise sums of large arrays.
     3315Note that none of these examples explicitly declare any concurrency or parallelism objects.
    26363316
    26373317\begin{table}
     
    26393319\begin{tabular}[t]{|c|c|c|}
    26403320Sequential & Library Parallel & Language Parallel \\
    2641 \begin{cfacode}[tabsize=3]
     3321\begin{cfa}[tabsize=3]
    26423322void big_sum(
    26433323        int* a, int* b,
     
    26633343//... fill in a & b
    26643344big_sum(a,b,c,10000);
    2665 \end{cfacode} &\begin{cfacode}[tabsize=3]
     3345\end{cfa} &\begin{cfa}[tabsize=3]
    26663346void big_sum(
    26673347        int* a, int* b,
     
    26873367//... fill in a & b
    26883368big_sum(a,b,c,10000);
    2689 \end{cfacode}&\begin{cfacode}[tabsize=3]
     3369\end{cfa}&\begin{cfa}[tabsize=3]
    26903370void big_sum(
    26913371        int* a, int* b,
     
    27113391//... fill in a & b
    27123392big_sum(a,b,c,10000);
    2713 \end{cfacode}
     3393\end{cfa}
    27143394\end{tabular}
    27153395\end{center}
    27163396\caption{For loop to sum numbers: Sequential, using library parallelism and language parallelism.}
    2717 \label{lst:parfor}
     3397\label{f:parfor}
    27183398\end{table}
    27193399
    2720 Implicit parallelism is a restrictive solution and therefore has its limitations. However, it is a quick and simple approach to parallelism, which may very well be sufficient for smaller applications and reduces the amount of boilerplate needed to start benefiting from parallelism in modern CPUs.
     3400Implicit parallelism is a restrictive solution and therefore has its limitations.
     3401However, it is a quick and simple approach to parallelism, which may very well be sufficient for smaller applications and reduces the amount of boilerplate needed to start benefiting from parallelism in modern CPUs.
    27213402
    27223403
     
    27313412% B I B L I O G R A P H Y
    27323413% -----------------------------
    2733 \bibliographystyle{plain}
     3414%\bibliographystyle{plain}
    27343415\bibliography{pl,local}
    27353416
  • doc/papers/concurrency/annex/local.bib

    r2efe4b8 r1cdfa82  
    2121@string{pldi="Programming Language Design and Implementation"}
    2222
    23 
    24 @article{HPP:Study,
    25         keywords        = {Parallel, Productivity},
    26         author  = {Lorin Hochstein and Jeff Carver and Forrest Shull and Sima Asgari and Victor Basili and Jeffrey K. Hollingsworth and Marvin V. Zelkowitz },
    27         title   = {Parallel Programmer Productivity: A Case Study of Novice Parallel Programmers},
     23@inproceedings{Hochstein05,
     24    keywords    = {Application software; Computer aided software engineering; Concurrent computing; Educational
     25                  institutions; High performance computing; Humans; Instruments; Productivity; Programming profession;
     26                  Software engineering},
     27    author      = {Lorin Hochstein and Jeff Carver and Forrest Shull and Sima Asgari and Victor Basili and Jeffrey K. Hollingsworth and Marvin V. Zelkowitz},
     28    title       = {Parallel Programmer Productivity: A Case Study of Novice Parallel Programmers},
     29    booktitle   = {Supercomputing, 2005. Proceedings of the ACM/IEEE SC 2005 Conference},
     30    publisher   = {IEEE},
     31    year        = {2005},
     32    pages       = {35-35},
     33    month       = nov,
    2834}
    2935
     
    3541}
    3642
    37 @article{TBB,
    38         key     = {TBB},
    39         keywords        = {Intel, TBB},
    40         title   = {Intel Thread Building Blocks},
    41         note            = "\url{https://www.threadingbuildingblocks.org/}"
     43@misc{TBB,
     44    keywords    = {Intel, TBB},
     45    key         = {TBB},
     46    title       = {Thread Building Blocks},
     47    howpublished= {Intel, \url{https://www.threadingbuildingblocks.org}},
     48    note        = {Accessed: 2018-3},
    4249}
    4350
     
    4855        title   = {C$\forall$ Programmming Language},
    4956        note    = {\url{https://plg.uwaterloo.ca/~cforall}},
    50 }
    51 
    52 @mastersthesis{rob-thesis,
    53         keywords        = {Constructors, Destructors, Tuples},
    54         author  = {Rob Schluntz},
    55         title   = {Resource Management and Tuples in Cforall},
    56         year            = 2017,
    57         school  = {University of Waterloo},
    58         note    = {\url{https://uwspace.uwaterloo.ca/handle/10012/11830}},
    5957}
    6058
  • doc/papers/concurrency/style/cfa-format.tex

    r2efe4b8 r1cdfa82  
    1 \usepackage[usenames,dvipsnames]{xcolor}
     1%\usepackage[usenames,dvipsnames]{xcolor}
    22\usepackage{listings}
    33\usepackage{inconsolata}
     
    1111% from https://gist.github.com/nikolajquorning/92bbbeef32e1dd80105c9bf2daceb89a
    1212\lstdefinelanguage{sml} {
    13   morekeywords= {
    14     EQUAL, GREATER, LESS, NONE, SOME, abstraction, abstype, and, andalso, array, as, before, bool, case, char, datatype, do, else, end, eqtype, exception, exn, false, fn, fun, functor, handle, if, in, include, infix, infixr, int, let, list, local, nil, nonfix, not, o, of, op, open, option, orelse, overload, print, raise, real, rec, ref, sharing, sig, signature, string, struct, structure, substring, then, true, type, unit, val, vector, where, while, with, withtype, word
    15   },
    16   morestring=[b]",
    17   morecomment=[s]{(*}{*)},
     13        morekeywords= {
     14                EQUAL, GREATER, LESS, NONE, SOME, abstraction, abstype, and, andalso, array, as, before,
     15                bool, case, char, datatype, do, else, end, eqtype, exception, exn, false, fn, fun, functor,
     16                handle, if, in, include, infix, infixr, int, let, list, local, nil, nonfix, not, o, of, op,
     17                open, option, orelse, overload, print, raise, real, rec, ref, sharing, sig, signature,
     18                string, struct, structure, substring, then, true, type, unit, val, vector, where, while,
     19                with, withtype, word
     20    },
     21    morestring=[b]",
     22    morecomment=[s]{(*}{*)},
    1823}
    1924
    2025\lstdefinelanguage{D}{
    21   % Keywords
    22   morekeywords=[1]{
    23     abstract, alias, align, auto, body, break, cast, catch, class, const,
    24     continue, debug, delegate, delete, deprecated, do, else, enum, export,
    25     false, final, finally, for, foreach, foreach_reverse, function, goto, if,
    26     immutable, import, in, inout, interface, invariant, is, lazy, macro, mixin,
    27     module, new, nothrow, null, out, override, package, pragma, private,
    28     protected, public, pure, ref, return, shared, static, struct, super,
    29     switch, synchronized, template, this, throw, true, try, typedef, typeid,
    30     typeof, union, unittest, volatile, while, with
    31   },
    32   % Special identifiers, common functions
    33   morekeywords=[2]{enforce},
    34   % Ugly identifiers
    35   morekeywords=[3]{
    36     __DATE__, __EOF__, __FILE__, __LINE__, __TIMESTAMP__, __TIME__, __VENDOR__,
    37     __VERSION__, __ctfe, __gshared, __monitor, __thread, __vptr, _argptr,
    38     _arguments, _ctor, _dtor
    39   },
    40   % Basic types
    41   morekeywords=[4]{
    42      byte, ubyte, short, ushort, int, uint, long, ulong, cent, ucent, void,
    43      bool, bit, float, double, real, ushort, int, uint, long, ulong, float,
    44      char, wchar, dchar, string, wstring, dstring, ireal, ifloat, idouble,
    45      creal, cfloat, cdouble, size_t, ptrdiff_t, sizediff_t, equals_t, hash_t
    46   },
    47   % Strings
    48   morestring=[b]{"},
    49   morestring=[b]{'},
    50   morestring=[b]{`},
    51   % Comments
    52   comment=[l]{//},
    53   morecomment=[s]{/*}{*/},
    54   morecomment=[s][\color{blue}]{/**}{*/},
    55   morecomment=[n]{/+}{+/},
    56   morecomment=[n][\color{blue}]{/++}{+/},
    57   % Options
    58   sensitive=true
     26        % Keywords
     27        morekeywords=[1]{
     28                abstract, alias, align, auto, body, break, cast, catch, class, const, continue, debug,
     29                delegate, delete, deprecated, do, else, enum, export, false, final, finally, for, foreach,
     30                foreach_reverse, function, goto, if, immutable, import, in, inout, interface, invariant, is,
     31                lazy, macro, mixin, module, new, nothrow, null, out, override, package, pragma, private,
     32                protected, public, pure, ref, return, shared, static, struct, super, switch, synchronized,
     33                template, this, throw, true, try, typedef, typeid, typeof, union, unittest, volatile, while,
     34                with
     35        },
     36        % Special identifiers, common functions
     37        morekeywords=[2]{enforce},
     38        % Ugly identifiers
     39        morekeywords=[3]{
     40                __DATE__, __EOF__, __FILE__, __LINE__, __TIMESTAMP__, __TIME__, __VENDOR__,
     41                __VERSION__, __ctfe, __gshared, __monitor, __thread, __vptr, _argptr,
     42                _arguments, _ctor, _dtor
     43        },
     44        % Basic types
     45        morekeywords=[4]{
     46                byte, ubyte, short, ushort, int, uint, long, ulong, cent, ucent, void, bool, bit, float,
     47                double, real, ushort, int, uint, long, ulong, float, char, wchar, dchar, string, wstring,
     48                dstring, ireal, ifloat, idouble, creal, cfloat, cdouble, size_t, ptrdiff_t, sizediff_t,
     49                equals_t, hash_t
     50        },
     51        % Strings
     52        morestring=[b]{"},
     53        morestring=[b]{'},
     54        morestring=[b]{`},
     55        % Comments
     56        comment=[l]{//},
     57        morecomment=[s]{/*}{*/},
     58        morecomment=[s][\color{blue}]{/**}{*/},
     59        morecomment=[n]{/+}{+/},
     60        morecomment=[n][\color{blue}]{/++}{+/},
     61        % Options
     62        sensitive=true
    5963}
    6064
    6165\lstdefinelanguage{rust}{
    62   % Keywords
    63   morekeywords=[1]{
    64     abstract, alignof, as, become, box,
    65     break, const, continue, crate, do,
    66     else, enum, extern, false, final,
    67     fn, for, if, impl, in,
    68     let, loop, macro, match, mod,
    69     move, mut, offsetof, override, priv,
    70     proc, pub, pure, ref, return,
    71     Self, self, sizeof, static, struct,
    72     super, trait, true,  type, typeof,
    73     unsafe, unsized, use, virtual, where,
    74     while, yield
    75   },
    76   % Strings
    77   morestring=[b]{"},
    78   % Comments
    79   comment=[l]{//},
    80   morecomment=[s]{/*}{*/},
    81   % Options
    82   sensitive=true
     66        % Keywords
     67        morekeywords=[1]{
     68                abstract, alignof, as, become, box, break, const, continue, crate, do, else, enum, extern,
     69                false, final, fn, for, if, impl, in, let, loop, macro, match, mod, move, mut, offsetof,
     70                override, priv, proc, pub, pure, ref, return, Self, self, sizeof, static, struct, super,
     71                trait, true, type, typeof, unsafe, unsized, use, virtual, where, while, yield
     72        },
     73        % Strings
     74        morestring=[b]{"},
     75        % Comments
     76        comment=[l]{//},
     77        morecomment=[s]{/*}{*/},
     78        % Options
     79        sensitive=true
    8380}
    8481
    8582\lstdefinelanguage{pseudo}{
    86         morekeywords={string,uint,int,bool,float},%
    87         sensitive=true,%
    88         morecomment=[l]{//},%
    89         morecomment=[s]{/*}{*/},%
    90         morestring=[b]',%
    91         morestring=[b]",%
    92         morestring=[s]{`}{`},%
    93 }%
     83        morekeywords={string,uint,int,bool,float},
     84        sensitive=true,
     85        morecomment=[l]{//},
     86        morecomment=[s]{/*}{*/},
     87        morestring=[b]',
     88        morestring=[b]",
     89        morestring=[s]{`}{`},
     90}
    9491
    9592\newcommand{\KWC}{K-W C\xspace}
    9693
    9794\lstdefinestyle{pseudoStyle}{
    98   escapeinside={@@},
    99   basicstyle=\linespread{0.9}\sf\footnotesize,          % reduce line spacing and use typewriter font
    100   keywordstyle=\bfseries\color{blue},
    101   keywordstyle=[2]\bfseries\color{Plum},
    102   commentstyle=\itshape\color{OliveGreen},                  % green and italic comments
    103   identifierstyle=\color{identifierCol},
    104   stringstyle=\sf\color{Mahogany},                                % use sanserif font
    105   mathescape=true,
    106   columns=fixed,
    107   aboveskip=4pt,                                  % spacing above/below code block
    108   belowskip=3pt,
    109   keepspaces=true,
    110   tabsize=4,
    111   % frame=lines,
    112   literate=,
    113   showlines=true,                                % show blank lines at end of code
    114   showspaces=false,
    115   showstringspaces=false,
    116   escapechar=\$,
    117   xleftmargin=\parindentlnth,                     % indent code to paragraph indentation
    118   moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
    119   % moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
    120   % moredelim=** allows cumulative application
     95        escapeinside={@@},
     96        basicstyle=\linespread{0.9}\sf\footnotesize,            % reduce line spacing and use typewriter font
     97        keywordstyle=\bfseries\color{blue},
     98        keywordstyle=[2]\bfseries\color{Plum},
     99        commentstyle=\itshape\color{OliveGreen},                    % green and italic comments
     100        identifierstyle=\color{identifierCol},
     101        stringstyle=\sf\color{Mahogany},                                          % use sanserif font
     102        mathescape=true,
     103        columns=fixed,
     104        aboveskip=4pt,                                                            % spacing above/below code block
     105        belowskip=3pt,
     106        keepspaces=true,
     107        tabsize=4,
     108        % frame=lines,
     109        literate=,
     110        showlines=true,                                                          % show blank lines at end of code
     111        showspaces=false,
     112        showstringspaces=false,
     113        escapechar=\$,
     114        xleftmargin=\parindentlnth,                                  % indent code to paragraph indentation
     115        moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
     116        % moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
     117        % moredelim=** allows cumulative application
    121118}
    122119
    123120\lstdefinestyle{defaultStyle}{
    124   escapeinside={@@},
    125   basicstyle=\linespread{0.9}\tt\footnotesize,          % reduce line spacing and use typewriter font
    126   keywordstyle=\bfseries\color{blue},
    127   keywordstyle=[2]\bfseries\color{Plum},
    128   commentstyle=\itshape\color{OliveGreen},                  % green and italic comments
    129   identifierstyle=\color{identifierCol},
    130   stringstyle=\sf\color{Mahogany},                                % use sanserif font
    131   mathescape=true,
    132   columns=fixed,
    133   aboveskip=4pt,                                  % spacing above/below code block
    134   belowskip=3pt,
    135   keepspaces=true,
    136   tabsize=4,
    137   % frame=lines,
    138   literate=,
    139   showlines=true,                                % show blank lines at end of code
    140   showspaces=false,
    141   showstringspaces=false,
    142   escapechar=\$,
    143   xleftmargin=\parindentlnth,                     % indent code to paragraph indentation
    144   moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
    145   % moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
    146   % moredelim=** allows cumulative application
     121        escapeinside={@@},
     122        basicstyle=\linespread{0.9}\tt\footnotesize,            % reduce line spacing and use typewriter font
     123        keywordstyle=\bfseries\color{blue},
     124        keywordstyle=[2]\bfseries\color{Plum},
     125        commentstyle=\itshape\color{OliveGreen},                    % green and italic comments
     126        identifierstyle=\color{identifierCol},
     127        stringstyle=\sf\color{Mahogany},                                          % use sanserif font
     128        mathescape=true,
     129        columns=fixed,
     130        aboveskip=4pt,                                                            % spacing above/below code block
     131        belowskip=3pt,
     132        keepspaces=true,
     133        tabsize=4,
     134        % frame=lines,
     135        literate=,
     136        showlines=true,                                                          % show blank lines at end of code
     137        showspaces=false,
     138        showstringspaces=false,
     139        escapechar=\$,
     140        xleftmargin=\parindentlnth,                                  % indent code to paragraph indentation
     141        moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
     142        % moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
     143        % moredelim=** allows cumulative application
    147144}
    148145
    149146\lstdefinestyle{cfaStyle}{
    150   escapeinside={@@},
    151   basicstyle=\linespread{0.9}\tt\footnotesize,          % reduce line spacing and use typewriter font
    152   keywordstyle=\bfseries\color{blue},
    153   keywordstyle=[2]\bfseries\color{Plum},
    154   commentstyle=\sf\itshape\color{OliveGreen},             % green and italic comments
    155   identifierstyle=\color{identifierCol},
    156   stringstyle=\sf\color{Mahogany},                                % use sanserif font
    157   mathescape=true,
    158   columns=fixed,
    159   aboveskip=4pt,                                  % spacing above/below code block
    160   belowskip=3pt,
    161   keepspaces=true,
    162   tabsize=4,
    163   % frame=lines,
    164   literate=,
    165   showlines=true,                                 % show blank lines at end of code
    166   showspaces=false,
    167   showstringspaces=false,
    168   escapechar=\$,
    169   xleftmargin=\parindentlnth,                     % indent code to paragraph indentation
    170   moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
    171   morekeywords=[2]{accept, signal, signal_block, wait, waitfor},
     147        escapeinside={@@},
     148        basicstyle=\linespread{0.9}\sf,         % reduce line spacing and use typewriter font
     149%  keywordstyle=\bfseries\color{blue},
     150        keywordstyle=[2]\bfseries\color{red},
     151%  commentstyle=\sf\itshape\color{OliveGreen},            % green and italic comments
     152        identifierstyle=\color{identifierCol},
     153%  stringstyle=\sf\color{Mahogany},                                       % use sanserif font
     154        stringstyle=\tt,                                                                                % use typewriter font
     155        mathescape=true,
     156        columns=fixed,
     157        aboveskip=4pt,                                                            % spacing above/below code block
     158        belowskip=3pt,
     159        keepspaces=true,
     160        tabsize=4,
     161        % frame=lines,
     162        literate=,
     163        showlines=true,                                                          % show blank lines at end of code
     164        showspaces=false,
     165        showstringspaces=false,
     166        escapechar=\$,
     167        xleftmargin=\parindentlnth,                                  % indent code to paragraph indentation
     168        moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
     169        morekeywords=[2]{accept, signal, signal_block, wait, waitfor},
    172170}
    173171
     
    175173
    176174\lstnewenvironment{ccode}[1][]{
    177   \lstset{
    178     language = C,
    179     style=defaultStyle,
    180     captionpos=b,
    181     #1
    182   }
     175        \lstset{
     176                language = C,
     177                style=defaultStyle,
     178                captionpos=b,
     179                #1
     180        }
    183181}{}
    184182
    185183\lstnewenvironment{cfacode}[1][]{
    186   \lstset{
    187     language = CFA,
    188     style=cfaStyle,
    189     captionpos=b,
    190     #1
    191   }
     184        \lstset{
     185                language = CFA,
     186                style=cfaStyle,
     187                captionpos=b,
     188                #1
     189        }
    192190}{}
    193191
    194192\lstnewenvironment{pseudo}[1][]{
    195   \lstset{
    196     language = pseudo,
    197     style=pseudoStyle,
    198     captionpos=b,
    199     #1
    200   }
     193        \lstset{
     194                language = pseudo,
     195                style=pseudoStyle,
     196                captionpos=b,
     197                #1
     198        }
    201199}{}
    202200
    203201\lstnewenvironment{cppcode}[1][]{
    204   \lstset{
    205     language = c++,
    206     style=defaultStyle,
    207     captionpos=b,
    208     #1
    209   }
     202        \lstset{
     203                language = c++,
     204                style=defaultStyle,
     205                captionpos=b,
     206                #1
     207        }
    210208}{}
    211209
    212210\lstnewenvironment{ucppcode}[1][]{
    213   \lstset{
    214     language = c++,
    215     style=defaultStyle,
    216     captionpos=b,
    217     #1
    218   }
     211        \lstset{
     212                language = c++,
     213                style=defaultStyle,
     214                captionpos=b,
     215                #1
     216        }
    219217}{}
    220218
    221219\lstnewenvironment{javacode}[1][]{
    222   \lstset{
    223     language = java,
    224     style=defaultStyle,
    225     captionpos=b,
    226     #1
    227   }
     220        \lstset{
     221                language = java,
     222                style=defaultStyle,
     223                captionpos=b,
     224                #1
     225        }
    228226}{}
    229227
    230228\lstnewenvironment{scalacode}[1][]{
    231   \lstset{
    232     language = scala,
    233     style=defaultStyle,
    234     captionpos=b,
    235     #1
    236   }
     229        \lstset{
     230                language = scala,
     231                style=defaultStyle,
     232                captionpos=b,
     233                #1
     234        }
    237235}{}
    238236
    239237\lstnewenvironment{smlcode}[1][]{
    240   \lstset{
    241     language = sml,
    242     style=defaultStyle,
    243     captionpos=b,
    244     #1
    245   }
     238        \lstset{
     239                language = sml,
     240                style=defaultStyle,
     241                captionpos=b,
     242                #1
     243        }
    246244}{}
    247245
    248246\lstnewenvironment{dcode}[1][]{
    249   \lstset{
    250     language = D,
    251     style=defaultStyle,
    252     captionpos=b,
    253     #1
    254   }
     247        \lstset{
     248                language = D,
     249                style=defaultStyle,
     250                captionpos=b,
     251                #1
     252        }
    255253}{}
    256254
    257255\lstnewenvironment{rustcode}[1][]{
    258   \lstset{
    259     language = rust,
    260     style=defaultStyle,
    261     captionpos=b,
    262     #1
    263   }
     256        \lstset{
     257                language = rust,
     258                style=defaultStyle,
     259                captionpos=b,
     260                #1
     261        }
    264262}{}
    265263
    266264\lstnewenvironment{gocode}[1][]{
    267   \lstset{
    268     language = Golang,
    269     style=defaultStyle,
    270     captionpos=b,
    271     #1
    272   }
     265        \lstset{
     266                language = Golang,
     267                style=defaultStyle,
     268                captionpos=b,
     269                #1
     270        }
    273271}{}
    274272
     
    278276\newcommand{\code}[1]{\lstinline[language=CFA,style=cfaStyle]{#1}}
    279277\newcommand{\pscode}[1]{\lstinline[language=pseudo,style=pseudoStyle]{#1}}
     278
     279% Local Variables: %
     280% tab-width: 4 %
     281% fill-column: 100 %
     282% End: %
  • doc/papers/general/.gitignore

    r2efe4b8 r1cdfa82  
    33*.pdf
    44*.ps
     5
     6Paper.tex.plain
     7mail
     8Paper.out.ps
     9WileyNJD-AMA.bst
  • doc/papers/general/Makefile

    r2efe4b8 r1cdfa82  
    33Build = build
    44Figures = figures
    5 Macros = AMA/AMA-stix/ama
     5Macros = ../AMA/AMA-stix/ama
    66TeXLIB = .:${Macros}:${Build}:../../bibliography:
    77LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error -output-directory=${Build}
     
    5151
    5252${BASE}.ps : ${BASE}.dvi
    53         dvips -o $@ ${Build}/$<
     53        dvips ${Build}/$< -o $@
    5454
    5555${BASE}.dvi : Makefile ${Build} ${BASE}.out.ps WileyNJD-AMA.bst ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \
     
    7070
    7171${BASE}.out.ps:
    72         ln -s build/Paper.out.ps .
     72        ln -fs build/Paper.out.ps .
    7373
    7474WileyNJD-AMA.bst:
    75         ln -s AMA/AMA-stix/ama/WileyNJD-AMA.bst .
     75        ln -fs ../AMA/AMA-stix/ama/WileyNJD-AMA.bst .
    7676
    7777${GRAPHS} : timing.gp timing.dat
  • doc/papers/general/Paper.tex

    r2efe4b8 r1cdfa82  
    88
    99\raggedbottom
     10
     11%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     12
     13% Latex packages used in the document.
    1014
    1115\usepackage{epic,eepic}
     
    1418\usepackage{upquote}                                            % switch curled `'" to straight
    1519\usepackage{listings}                                           % format program code
     20\captionsetup{justification=raggedright,singlelinecheck=false}
    1621%\usepackage{enumitem}
    1722%\setlist[itemize]{topsep=3pt,itemsep=2pt,parsep=0pt}% global
    1823%\usepackage{rotating}
     24
     25\hypersetup{breaklinks=true}
    1926\definecolor{ForestGreen}{cmyk}{1, 0, 0.99995, 0}
    20 \hypersetup{breaklinks=true}
    2127
    2228\usepackage[pagewise]{lineno}
    2329\renewcommand{\linenumberfont}{\scriptsize\sffamily}
    2430
    25 \lefthyphenmin=4                                                        % hyphen only after 4 characters
    26 \righthyphenmin=4
     31\lefthyphenmin=3                                                        % hyphen only after 4 characters
     32\righthyphenmin=3
     33
     34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    2735
    2836% Names used in the document.
     
    7987% Latin abbreviation
    8088\newcommand{\abbrevFont}{\textit}                       % set empty for no italics
    81 \newcommand{\EG}{\abbrevFont{e}.\abbrevFont{g}.}
     89\@ifundefined{eg}{
     90\newcommand{\EG}{\abbrevFont{e}\abbrevFont{g}}
    8291\newcommand*{\eg}{%
    8392        \@ifnextchar{,}{\EG}%
    8493                {\@ifnextchar{:}{\EG}%
    8594                        {\EG,\xspace}}%
    86 }%
    87 \newcommand{\IE}{\abbrevFont{i}.\abbrevFont{e}.}
     95}}{}%
     96\@ifundefined{ie}{
     97\newcommand{\IE}{\abbrevFont{i}\abbrevFont{e}}
    8898\newcommand*{\ie}{%
    8999        \@ifnextchar{,}{\IE}%
    90100                {\@ifnextchar{:}{\IE}%
    91101                        {\IE,\xspace}}%
    92 }%
     102}}{}%
     103\@ifundefined{etc}{
    93104\newcommand{\ETC}{\abbrevFont{etc}}
    94105\newcommand*{\etc}{%
    95106        \@ifnextchar{.}{\ETC}%
    96107        {\ETC.\xspace}%
    97 }%
    98 %\newcommand{\ETAL}{\abbrevFont{et}~\abbrevFont{al}}
    99 %\newcommand*{\etal}{%
    100 %       \@ifnextchar{.}{\protect\ETAL}%
    101 %               {\protect\ETAL.\xspace}%
    102 %}%
     108}}{}%
     109\@ifundefined{etal}{
     110\newcommand{\ETAL}{\abbrevFont{et}~\abbrevFont{al}}
     111\newcommand*{\etal}{%
     112        \@ifnextchar{.}{\protect\ETAL}%
     113                {\protect\ETAL.\xspace}%
     114}}{}%
     115\@ifundefined{viz}{
    103116\newcommand{\VIZ}{\abbrevFont{viz}}
    104117\newcommand*{\viz}{%
    105118        \@ifnextchar{.}{\VIZ}%
    106119                {\VIZ.\xspace}%
    107 }%
     120}}{}%
    108121\makeatother
    109122
     
    118131\lstdefinelanguage{CFA}[ANSI]{C}{
    119132        morekeywords={
    120                 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, __attribute,
    121                 __attribute__, auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__,
    122                 __const, __const__, disable, dtype, enable, exception, __extension__, fallthrough, fallthru,
    123                 finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, _Noreturn, one_t,
    124                 otype, restrict, _Static_assert, throw, throwResume, trait, try, ttype, typeof, __typeof,
    125                 __typeof__, virtual, with, zero_t},
    126         morekeywords=[2]{
    127                 _Atomic, coroutine, is_coroutine, is_monitor, is_thread, monitor, mutex, nomutex, or,
    128                 resume, suspend, thread, _Thread_local, waitfor, when, yield},
     133                _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, __attribute, __attribute__,
     134                auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__, __const, __const__,
     135                coroutine, disable, dtype, enable, exception, __extension__, fallthrough, fallthru, finally,
     136                __float80, float80, __float128, float128, forall, ftype, _Generic, _Imaginary, __imag, __imag__,
     137                inline, __inline, __inline__, __int128, int128, __label__, monitor, mutex, _Noreturn, one_t, or,
     138                otype, restrict, __restrict, __restrict__, __signed, __signed__, _Static_assert, thread,
     139                _Thread_local, throw, throwResume, timeout, trait, try, ttype, typeof, __typeof, __typeof__,
     140                virtual, __volatile, __volatile__, waitfor, when, with, zero_t},
    129141        moredirectives={defined,include_next}%
    130142}
     
    147159literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.1ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptstyle\land\,$}}1
    148160        {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 % {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1
    149         {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.5ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex{\textgreater}}2,
     161        {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex{\textgreater}}2,
    150162moredelim=**[is][\color{red}]{`}{`},
    151163}% lstset
     
    158170{}
    159171
    160 
    161 \begin{document}
    162 \linenumbers                                            % comment out to turn off line numbering
     172% inline code @...@
     173\lstMakeShortInline@%
     174
    163175
    164176\title{\texorpdfstring{\protect\CFA : Adding Modern Programming Language Features to C}{Cforall : Adding Modern Programming Language Features to C}}
     
    167179\author[1]{Robert Schluntz}
    168180\author[1]{Peter A. Buhr*}
    169 
    170 \address[1]{\orgdiv{David R. Cheriton School of Computer Science}, \orgname{University of Waterloo}, \orgaddress{\state{Ontario}, \country{Canada}}}
    171 
    172 %\corres{*Aaron Moss, \email{a3moss@uwaterloo.ca}}
    173 \corres{*Peter A. Buhr, \email{pabuhr@uwaterloo.ca}}
    174 \presentaddress{David R. Cheriton School of Computer Science, University of Waterloo, Waterloo, ON, N2L 3G1, Canada}
    175 
    176 % inline code @...@
    177 \lstMakeShortInline@%
    178 
     181\authormark{MOSS \textsc{et al}}
     182
     183\address[1]{\orgdiv{Cheriton School of Computer Science}, \orgname{University of Waterloo}, \orgaddress{\state{Waterloo, ON}, \country{Canada}}}
     184
     185\corres{*Peter A. Buhr, Cheriton School of Computer Science, University of Waterloo, 200 University Avenue West, Waterloo, ON, N2L 3G1, Canada. \email{pabuhr{\char`\@}uwaterloo.ca}}
     186
     187\fundingInfo{Natural Sciences and Engineering Research Council of Canada}
    179188
    180189\abstract[Summary]{
     
    191200
    192201\keywords{generic types, tuple types, variadic types, polymorphic functions, C, Cforall}
     202
     203
     204\begin{document}
     205\linenumbers                                            % comment out to turn off line numbering
    193206
    194207\maketitle
     
    214227Love it or hate it, C is extremely popular, highly used, and one of the few systems languages.
    215228In many cases, \CC is often used solely as a better C.
    216 Nonetheless, C, first standardized over thirty years ago, lacks many features that make programming in more modern languages safer and more productive.
    217 
    218 \CFA (pronounced ``C-for-all'', and written \CFA or Cforall) is an evolutionary extension of the C programming language that aims to add modern language features to C while maintaining both source compatibility with C and a familiar programming model for programmers.
     229Nevertheless, C, first standardized over thirty years ago, lacks many features that make programming in more modern languages safer and more productive.
     230
     231\CFA (pronounced ``C-for-all'', and written \CFA or Cforall) is an evolutionary extension of the C programming language that aims to add modern language features to C, while maintaining both source and runtime compatibility with C and a familiar programming model for programmers.
    219232The four key design goals for \CFA~\cite{Bilson03} are:
    220233(1) The behaviour of standard C code must remain the same when translated by a \CFA compiler as when translated by a C compiler;
     
    316329A simple example is leveraging the existing type-unsafe (@void *@) C @bsearch@ to binary search a sorted float array:
    317330\begin{cfa}
    318 void * bsearch( const void * key, const void * base, size_t nmemb, size_t size,
    319                                          int (* compar)( const void *, const void * ));
     331void * bsearch( const void * key, const void * base, size_t nmemb, size_t size, int (* compar)( const void *, const void * ));
    320332int comp( const void * t1, const void * t2 ) {
    321333         return *(double *)t1 < *(double *)t2 ? -1 : *(double *)t2 < *(double *)t1 ? 1 : 0;
     
    324336double * val = (double *)bsearch( &key, vals, 10, sizeof(vals[0]), comp ); $\C{// search sorted array}$
    325337\end{cfa}
    326 which can be augmented simply with a generalized, type-safe, \CFA-overloaded wrappers:
     338which can be augmented simply with generalized, type-safe, \CFA-overloaded wrappers:
    327339\begin{cfa}
    328340forall( otype T | { int ?<?( T, T ); } ) T * bsearch( T key, const T * arr, size_t size ) {
     
    386398        T ?++( T * );
    387399};
    388 forall( otype T `| summable( T )` ) T sum( T a[$\,$], size_t size ) {  // use trait
     400forall( otype T `| summable( T )` ) T sum( T a[$\,$], size_t size ) {$\C{// use trait}$
    389401        `T` total = { `0` };                                    $\C{// instantiate T from 0 by calling its constructor}$
    390402        for ( unsigned int i = 0; i < size; i += 1 ) total `+=` a[i]; $\C{// select appropriate +}$
     
    564576        return (scalar(U)){ a.value + b.value };
    565577}
    566 scalar(metres) half_marathon = { 21093 };
    567 scalar(litres) swimming_pool = { 2500000 };
     578scalar(metres) half_marathon = { 21_093 };
     579scalar(litres) swimming_pool = { 2_500_000 };
    568580scalar(metres) marathon = half_marathon + half_marathon;
    569581scalar(litres) two_pools = swimming_pool + swimming_pool;
     
    663675\begin{cfa}
    664676int f( int, int );
    665 int g( [int, int] );
    666 int h( int, [int, int] );
     677[int] g( [int, int] );
     678[int] h( int, [int, int] );
    667679[int, int] x;
    668680int y;
     
    698710This example shows mass, multiple, and cascading assignment used in one expression:
    699711\begin{cfa}
    700 void f( [int, int] );
     712[void] f( [int, int] );
    701713f( [x, y] = z = 1.5 );                                          $\C{// assignments in parameter list}$
    702714\end{cfa}
     
    712724\end{cfa}
    713725Here, the mass assignment sets all members of @s@ to zero.
    714 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, drop, and duplicate components).
     726Since 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, drop, and duplicate components).
    715727\begin{cfa}
    716728[int, int, long, double] x;
     
    806818Flattening and restructuring conversions are also applied to tuple types in polymorphic type assertions.
    807819\begin{cfa}
    808 int f( [int, double], double );
     820[int] f( [int, double], double );
    809821forall( otype T, otype U | { T f( T, U, U ); } ) void g( T, U );
    810822g( 5, 10.21 );
     
    10211033\lstMakeShortInline@%
    10221034\end{cquote}
    1023 for a contiguous list:\footnote{gcc has the same mechanism but awkward syntax, \lstinline@2 ...42@, because a space is required after a number, otherwise the period is a decimal point.}
     1035for a contiguous list:\footnote{gcc has the same mechanism but awkward syntax, \lstinline@2 ...42@, as a space is required after a number, otherwise the first period is a decimal point.}
    10241036\begin{cquote}
    10251037\lstDeleteShortInline@%
     
    11181130
    11191131Finally, Figure~\ref{f:FallthroughStatement} shows @fallthrough@ may appear in contexts other than terminating a @case@ clause, and have an explicit transfer label allowing separate cases but common final-code for a set of cases.
    1120 The target label must be below the @fallthrough@, \ie @fallthrough@ cannot form a loop, and the label may not be nested in a control structure, \ie it must be at the same level as the @case@ clauses;
    1121 the target label may be case @default@.
     1132The target label must be below the @fallthrough@ and may not be nested in a control structure, \ie @fallthrough@ cannot form a loop, and the target label must be at the same or higher level as the containing @case@ clause and located at the same level as a @case@ clause;
     1133the target label may be case @default@, but only associated with the current @switch@/@choose@ statement.
    11221134
    11231135\begin{figure}
     
    11441156  case 4:
    11451157        ... `fallthrough common;`
    1146   common: // below fallthrough at same level as case clauses
     1158  `common`: // below fallthrough at same level as case clauses
    11471159        ...      // common code for cases 3 and 4
    11481160        // implicit break
     
    11541166\label{f:FallthroughStatement}
    11551167\end{figure}
    1156 
    1157 Collectively, these control-structure enhancements reduce programmer burden and increase readability and safety.
    11581168
    11591169
     
    15261536\end{cfa}
    15271537
     1538Collectively, these control-structure enhancements reduce programmer burden and increase readability and safety.
     1539
    15281540
    15291541\section{Declarations}
     
    18491861\begin{cfa}
    18501862struct S { double x, y; };
    1851 int i, j;
     1863int x, y;
    18521864void f( int & i, int & j, S & s, int v[] );
    1853 f( 3, i + j, (S){ 1.0, 7.0 }, (int [3]){ 1, 2, 3 } );   $\C{// pass rvalue to lvalue \(\Rightarrow\) implicit temporary}$
     1865f( 3, x + y, (S){ 1.0, 7.0 }, (int [3]){ 1, 2, 3 } ); $\C{// pass rvalue to lvalue \(\Rightarrow\) implicit temporary}$
    18541866\end{cfa}
    18551867This allows complex values to be succinctly and efficiently passed to functions, without the syntactic overhead of explicit definition of a temporary variable or the runtime cost of pass-by-value.
     
    18671879\lstDeleteShortInline@%
    18681880\begin{tabular}{@{}l@{\hspace{3em}}l|l@{}}
    1869 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C Type Nesting}}      & \multicolumn{1}{c}{\textbf{C Implicit Hoisting}}      & \multicolumn{1}{|c}{\textbf{\CFA}}    \\
     1881\multicolumn{1}{c@{\hspace{3em}}}{\textbf{C Type Nesting}}      & \multicolumn{1}{c|}{\textbf{C Implicit Hoisting}}     & \multicolumn{1}{c}{\textbf{\CFA}}     \\
    18701882\hline
    18711883\begin{cfa}
     
    19381950
    19391951One of the strengths (and weaknesses) of C is memory-management control, allowing resource release to be precisely specified versus unknown release with garbage-collected memory-management.
    1940 However, this manual approach is often verbose, and it is useful to manage resources other than memory (\eg file handles) using the same mechanism as memory.
     1952However, this manual approach is verbose, and it is useful to manage resources other than memory (\eg file handles) using the same mechanism as memory.
    19411953\CC addresses these issues using Resource Aquisition Is Initialization (RAII), implemented by means of \newterm{constructor} and \newterm{destructor} functions;
    19421954\CFA adopts constructors and destructors (and @finally@) to facilitate RAII.
     
    19902002{
    19912003        VLA  x,            y = { 20, 0x01 },     z = y; $\C{// z points to y}$
    1992         //      ?{}( x );  ?{}( y, 20, 0x01 );  ?{}( z, y );
     2004        //      ?{}( x );   ?{}( y, 20, 0x01 );   ?{}( z, y );
    19932005        ^x{};                                                                   $\C{// deallocate x}$
    19942006        x{};                                                                    $\C{// reallocate x}$
     
    20152027These semantics closely mirror the rule for implicit declaration of constructors in \CC\cite[p.~186]{ANSI98:C++}.
    20162028
    2017 In some circumstance programmers may not wish to have constructor and destructor calls.
    2018 In these cases, \CFA provides the initialization syntax \lstinline|S x @= {}|, and the object becomes unmanaged, so implicit constructor and destructor calls are not generated.
    2019 Any C initializer can be the right-hand side of an \lstinline|@=| initializer, \eg \lstinline|VLA a @= { 0, 0x0 }|, with the usual C initialization semantics.
     2029In some circumstance programmers may not wish to have implicit constructor and destructor generation and calls.
     2030In these cases, \CFA provides the initialization syntax \lstinline|S x `@=` {}|, and the object becomes unmanaged, so implicit constructor and destructor calls are not generated.
     2031Any C initializer can be the right-hand side of an \lstinline|@=| initializer, \eg \lstinline|VLA a @= { 0, 0x0 }|, with the usual C initialization semantics.
     2032The same syntax can be used in a compound literal, \eg \lstinline|a = VLA`@`{ 0, 0x0 }|, to create a C-style literal.
    20202033The point of \lstinline|@=| is to provide a migration path from legacy C code to \CFA, by providing a mechanism to incrementally convert to implicit initialization.
    20212034
     
    20352048\subsection{Integral Suffixes}
    20362049
    2037 Additional integral suffixes are added to cover all the integral types and lengths.
     2050New integral suffixes @hh@ (half of half of @int@) for @char@, @h@ (half of @int@) for @short@, and @z@ for @size_t@, and length suffixes for 8, 16, 32, 64, and 128 bit integers.
     2051%Additional integral suffixes are added to cover all the integral types and lengths.
    20382052\begin{cquote}
    20392053\lstDeleteShortInline@%
     
    20412055\begin{cfa}
    2042205620_`hh`     // signed char
    2043 21_`hhu`   // unsigned char
     205721_`hh`u   // unsigned char
    2044205822_`h`       // signed short int
    2045 23_`uh`     // unsigned short int
    2046 24_`z`       // size_t
     205923_u`h`     // unsigned short int
     206024`z`         // size_t
    20472061\end{cfa}
    20482062&
    20492063\begin{cfa}
    2050206420_`L8`      // int8_t
    2051 21_`ul8`     // uint8_t
     206521_u`l8`     // uint8_t
    2052206622_`l16`     // int16_t
    2053 23_`ul16`   // uint16_t
     206723_u`l16`   // uint16_t
    2054206824_`l32`     // int32_t
    20552069\end{cfa}
    20562070&
    20572071\begin{cfa}
    2058 25_`ul32`      // uint32_t
     207225_u`l32`      // uint32_t
    2059207326_`l64`        // int64_t
    2060 27_`l64u`      // uint64_t
     207427_`l64`u      // uint64_t
    2061207526_`L128`     // int128
    2062 27_`L128u`   // unsigned int128
     207627_`L128`u   // unsigned int128
    20632077\end{cfa}
    20642078\end{tabular}
     
    20752089To provide this precision, \CFA introduces a new type @zero_t@ as the type of literal @0@ (somewhat analagous to @nullptr_t@ and @nullptr@ in \CCeleven);
    20762090@zero_t@ can only take the value @0@, but has implicit conversions to the integer and pointer types so that C code involving @0@ continues to work.
    2077 With this addition, \CFA rewrites @if (x)@ and similar expressions to @if ((x) != 0)@ or the appropriate analogue, and any type @T@ is ``truthy'' by defining an operator overload @int ?!=?(T, zero_t)@.
     2091With this addition, \CFA rewrites @if (x)@ and similar expressions to @if ( (x) != 0 )@ or the appropriate analogue, and any type @T@ is ``truthy'' by defining an operator overload @int ?!=?( T, zero_t )@.
    20782092\CC makes types truthy by adding a conversion to @bool@;
    20792093prior to the addition of explicit cast operators in \CCeleven, this approach had the pitfall of making truthy types transitively convertable to any numeric type;
     
    20912105
    20922106For readability, it is useful to associate units to scale literals, \eg weight (stone, pound, kilogram) or time (seconds, minutes, hours).
    2093 The left of Figure~\ref{f:UserLiteral} shows the \CFA alternative call-syntax (literal argument before function name), using the backquote, to convert basic literals into user literals.
     2107The left of Figure~\ref{f:UserLiteral} shows the \CFA alternative call-syntax (postfix: literal argument before function name), using the backquote, to convert basic literals into user literals.
    20942108The backquote is a small character, making the unit (function name) predominate.
    20952109For examples, the multi-precision integer-type in Section~\ref{s:MultiPrecisionIntegers} has user literals:
     
    20992113y = "12345678901234567890123456789"|`mp| + "12345678901234567890123456789"|`mp|;
    21002114\end{cfa}
    2101 Because \CFA uses a standard function, all types and literals are applicable, as well as overloading and conversions.
     2115Because \CFA uses a standard function, all types and literals are applicable, as well as overloading and conversions, where @?`@ denotes a postfix-function name and @`@ denotes a postfix-function call.
    21022116}%
     2117\begin{cquote}
     2118\lstset{language=CFA,moredelim=**[is][\color{red}]{|}{|},deletedelim=**[is][]{`}{`}}
     2119\lstDeleteShortInline@%
     2120\begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{\hspace{2\parindentlnth}}l@{\hspace{2\parindentlnth}}l@{}}
     2121\multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{postfix function}}        & \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{constant}}      & \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{variable/expression}}   & \multicolumn{1}{c}{\textbf{postfix pointer}}  \\
     2122\begin{cfa}
     2123int |?`h|( int s );
     2124int |?`h|( double s );
     2125int |?`m|( char c );
     2126int |?`m|( const char * s );
     2127int |?`t|( int a, int b, int c );
     2128\end{cfa}
     2129&
     2130\begin{cfa}
     21310 |`h|;
     21323.5|`h|;
     2133'1'|`m|;
     2134"123" "456"|`m|;
     2135[1,2,3]|`t|;
     2136\end{cfa}
     2137&
     2138\begin{cfa}
     2139int i = 7;
     2140i|`h|;
     2141(i + 3)|`h|;
     2142(i + 3.5)|`h|;
     2143
     2144\end{cfa}
     2145&
     2146\begin{cfa}
     2147int (* |?`p|)( int i );
     2148|?`p| = |?`h|;
     21493|`p|;
     2150i|`p|;
     2151(i + 3)|`p|;
     2152\end{cfa}
     2153\end{tabular}
     2154\lstMakeShortInline@%
     2155\end{cquote}
    21032156
    21042157The right of Figure~\ref{f:UserLiteral} shows the equivalent \CC version using the underscore for the call-syntax.
     
    21112164\lstset{language=CFA,moredelim=**[is][\color{red}]{|}{|},deletedelim=**[is][]{`}{`}}
    21122165\lstDeleteShortInline@%
    2113 \begin{tabular}{@{}l@{\hspace{\parindentlnth}}l@{}}
    2114 \multicolumn{1}{c@{\hspace{\parindentlnth}}}{\textbf{\CFA}}     & \multicolumn{1}{c}{\textbf{\CC}}      \\
     2166\begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
     2167\multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{c}{\textbf{\CC}}      \\
    21152168\begin{cfa}
    21162169struct W {
     
    22082261\begin{cfa}
    22092262MIN
    2210 
    22112263MAX
    2212 
    22132264PI
    22142265E
     
    22162267&
    22172268\begin{cfa}
    2218 SCHAR_MIN, CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, LLONG_MIN,
    2219                 FLT_MIN, DBL_MIN, LDBL_MIN
    2220 SCHAR_MAX, UCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX, LLONG_MAX,
    2221                 FLT_MAX, DBL_MAX, LDBL_MAX
     2269SCHAR_MIN, CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, LLONG_MIN, FLT_MIN, DBL_MIN, LDBL_MIN
     2270SCHAR_MAX, UCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX, LLONG_MAX, FLT_MAX, DBL_MAX, LDBL_MAX
    22222271M_PI, M_PIl
    22232272M_E, M_El
     
    23922441ip = (int *)malloc( sizeof( int ) ); memset( ip, fill, dim * sizeof( int ) );
    23932442ip = (int *)realloc( ip, 2 * dim * sizeof( int ) );
    2394 ip = (int *)realloc( ip, 4 * dim * sizeof( int ) );
    2395                         memset( ip, fill, 4 * dim * sizeof( int ) );
     2443ip = (int *)realloc( ip, 4 * dim * sizeof( int ) ); memset( ip, fill, 4 * dim * sizeof( int ) );
     2444
    23962445ip = memalign( 16, sizeof( int ) );
    23972446ip = memalign( 16, sizeof( int ) ); memset( ip, fill, sizeof( int ) );
  • doc/refrat/keywords.tex

    r2efe4b8 r1cdfa82  
    1111%% Created On       : Sun Aug  6 08:17:27 2017
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Wed Aug 30 22:10:10 2017
    14 %% Update Count     : 5
     13%% Last Modified On : Fri Apr  6 15:16:11 2018
     14%% Update Count     : 7
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616\begin{tabular}{@{}llllll@{}}
    1717\begin{tabular}{@{}l@{}}
    18 ©_At©                   \\
    1918©catch©                 \\
    2019©catchResume©   \\
    2120©choose©                \\
    2221©coroutine©             \\
     22©disable©               \\
    2323\end{tabular}
    2424&
    2525\begin{tabular}{@{}l@{}}
    26 ©disable©               \\
    2726©dtype©                 \\
    2827©enable©                \\
     28©exception©             \\
    2929©fallthrough©   \\
    3030©fallthru©              \\
     
    3535©forall©                \\
    3636©ftype©                 \\
    37 ©lvalue©                \\
    3837©monitor©               \\
     38©mutex©                 \\
    3939\end{tabular}
    4040&
    4141\begin{tabular}{@{}l@{}}
    42 ©mutex©                 \\
    4342©one_t©                 \\
    4443©otype©                 \\
    4544©throw©                 \\
    4645©throwResume©   \\
     46©trait©                 \\
    4747\end{tabular}
    4848&
    4949\begin{tabular}{@{}l@{}}
    50 ©trait©                 \\
    5150©try©                   \\
    5251©ttype©                 \\
    5352©virtual©               \\
    5453©waitfor©               \\
     54©when©                  \\
    5555\end{tabular}
    5656&
    5757\begin{tabular}{@{}l@{}}
    58 ©when©                  \\
    5958©with©                  \\
    6059©zero_t©                \\
     60                                \\
    6161                                \\
    6262                                \\
  • doc/user/user.tex

    r2efe4b8 r1cdfa82  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Tue Feb 13 08:31:21 2018
    14 %% Update Count     : 3161
     13%% Last Modified On : Sat Apr 14 19:04:30 2018
     14%% Update Count     : 3318
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    283283
    284284double key = 5.0, vals[10] = { /* 10 sorted floating values */ };
    285 double * val = (double *)bsearch( &key, vals, 10, sizeof(vals[0]), comp );      $\C{// search sorted array}$
     285double * val = (double *)bsearch( &key, vals, 10, sizeof(vals[0]), comp );      §\C{// search sorted array}§
    286286\end{lstlisting}
    287287which can be augmented simply with a polymorphic, type-safe, \CFA-overloaded wrappers:
     
    292292
    293293forall( otype T | { int ?<?( T, T ); } ) unsigned int bsearch( T key, const T * arr, size_t size ) {
    294         T * result = bsearch( key, arr, size ); $\C{// call first version}$
    295         return result ? result - arr : size; }  $\C{// pointer subtraction includes sizeof(T)}$
    296 
    297 double * val = bsearch( 5.0, vals, 10 );        $\C{// selection based on return type}$
     294        T * result = bsearch( key, arr, size ); §\C{// call first version}§
     295        return result ? result - arr : size; }  §\C{// pointer subtraction includes sizeof(T)}§
     296
     297double * val = bsearch( 5.0, vals, 10 );        §\C{// selection based on return type}§
    298298int posn = bsearch( 5.0, vals, 10 );
    299299\end{lstlisting}
     
    353353The 1999 C standard plus GNU extensions.
    354354\item
    355 \Indexc[deletekeywords=inline]{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{\lstinline[deletekeywords=inline]$-fgnu89-inline$}}
     355\Indexc[deletekeywords=inline]{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{\lstinline[deletekeywords=inline]@-fgnu89-inline@}}
    356356Use the traditional GNU semantics for inline routines in C99 mode, which allows inline routines in header files.
    357357\end{description}
     
    506506
    507507C, \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.
    508 \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$.
     508\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$.
    509509The 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)©.
    510510
     
    524524
    525525
    526 \section{\texorpdfstring{Labelled \LstKeywordStyle{continue} / \LstKeywordStyle{break}}{Labelled continue / break}}
     526\section{\texorpdfstring{Labelled \protect\lstinline@continue@ / \protect\lstinline@break@}{Labelled continue / break}}
    527527
    528528While C provides ©continue© and ©break© statements for altering control flow, both are restricted to one level of nesting for a particular control structure.
    529529Unfortunately, this restriction forces programmers to use \Indexc{goto} to achieve the equivalent control-flow for more than one level of nesting.
    530 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.
     530To 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.
    531531For both ©continue© and ©break©, the target label must be directly associated with a ©for©, ©while© or ©do© statement;
    532532for ©break©, the target label can also be associated with a ©switch©, ©if© or compound (©{}©) statement.
     
    613613\end{figure}
    614614
    615 Both labelled ©continue© and ©break© are a ©goto©\index{goto@\lstinline $goto$!restricted} restricted in the following ways:
     615Both labelled ©continue© and ©break© are a ©goto©\index{goto@\lstinline@goto@!restricted} restricted in the following ways:
    616616\begin{itemize}
    617617\item
     
    629629
    630630
    631 \section{\texorpdfstring{\LstKeywordStyle{switch} Statement}{switch Statement}}
     631\section{\texorpdfstring{\protect\lstinline@switch@ Statement}{switch Statement}}
    632632
    633633C allows a number of questionable forms for the ©switch© statement:
     
    834834
    835835
    836 \section{\texorpdfstring{\LstKeywordStyle{case} Clause}{case Clause}}
     836\section{\texorpdfstring{\protect\lstinline@case@ Clause}{case Clause}}
    837837
    838838C restricts the ©case© clause of a ©switch© statement to a single value.
     
    871871\end{tabular}
    872872\end{cquote}
    873 In addition, two forms of subranges are allowed to specify case values: a new \CFA form and an existing GNU C form.\footnote{
    874 The GNU C form \emph{requires} spaces around the ellipse.}
    875 \begin{cquote}
    876 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}}
    877 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{GNU C}}     \\
     873In addition, subranges are allowed to specify case values.\footnote{
     874gcc has the same mechanism but awkward syntax, \lstinline@2 ...42@, because a space is required after a number, otherwise the period is a decimal point.}
    878875\begin{cfa}
    879876switch ( i ) {
    880   case ®1~5:®
     877  case ®1~5:®                                   §\C{// 1, 2, 3, 4, 5}§
    881878        ...
    882   case ®10~15:®
     879  case ®10~15:®                                 §\C{// 10, 11, 12, 13, 14, 15}§
    883880        ...
    884881}
    885882\end{cfa}
    886 &
    887 \begin{cfa}
    888 switch ( i )
    889   case ®1 ... 5®:
    890         ...
    891   case ®10 ... 15®:
    892         ...
    893 }
    894 \end{cfa}
    895 &
    896 \begin{cfa}
    897 
    898 // 1, 2, 3, 4, 5
    899 
    900 // 10, 11, 12, 13, 14, 15
    901 
    902 
    903 \end{cfa}
    904 \end{tabular}
    905 \end{cquote}
    906883Lists of subranges are also allowed.
    907884\begin{cfa}
     
    910887
    911888
    912 \section{\texorpdfstring{\LstKeywordStyle{with} Clause / Statement}{with Clause / Statement}}
    913 \label{s:WithClauseStatement}
     889\section{\texorpdfstring{\protect\lstinline@with@ Statement}{with Statement}}
     890\label{s:WithStatement}
     891
     892Grouping heterogeneous data into \newterm{aggregate}s (structure/union) is a common programming practice, and an aggregate can be further organized into more complex structures, such as arrays and containers:
     893\begin{cfa}
     894struct S {                                                                      §\C{// aggregate}§
     895        char c;                                                                 §\C{// fields}§
     896        int i;
     897        double d;
     898};
     899S s, as[10];
     900\end{cfa}
     901However, functions manipulating aggregates must repeat the aggregate name to access its containing fields:
     902\begin{cfa}
     903void f( S s ) {
     904        `s.`c; `s.`i; `s.`d;                                    §\C{// access containing fields}§
     905}
     906\end{cfa}
     907which extends to multiple levels of qualification for nested aggregates.
     908A similar situation occurs in object-oriented programming, \eg \CC:
     909\begin{C++}
     910struct S {
     911        char c;                                                                 §\C{// fields}§
     912        int i;
     913        double d;
     914        void f() {                                                              §\C{// implicit ``this'' aggregate}§
     915                `this->`c; `this->`i; `this->`d;        §\C{// access containing fields}§
     916        }
     917}
     918\end{C++}
     919Object-oriented nesting of member functions in a \lstinline[language=C++]@class/struct@ allows eliding \lstinline[language=C++]$this->$ because of lexical scoping.
     920However, for other aggregate parameters, qualification is necessary:
     921\begin{cfa}
     922struct T { double m, n; };
     923int S::f( T & t ) {                                                     §\C{// multiple aggregate parameters}§
     924        c; i; d;                                                                §\C{\color{red}// this--{\textgreater}.c, this--{\textgreater}.i, this--{\textgreater}.d}§
     925        `t.`m; `t.`n;                                                   §\C{// must qualify}§
     926}
     927\end{cfa}
     928
     929To simplify the programmer experience, \CFA provides a @with@ statement (see Pascal~\cite[\S~4.F]{Pascal}) to elide aggregate qualification to fields by opening a scope containing the field identifiers.
     930Hence, the qualified fields become variables with the side-effect that it is easier to optimizing field references in a block.
     931\begin{cfa}
     932void f( S & this ) `with ( this )` {            §\C{// with statement}§
     933        c; i; d;                                                                §\C{\color{red}// this.c, this.i, this.d}§
     934}
     935\end{cfa}
     936with the generality of opening multiple aggregate-parameters:
     937\begin{cfa}
     938void f( S & s, T & t ) `with ( s, t )` {                §\C{// multiple aggregate parameters}§
     939        c; i; d;                                                                §\C{\color{red}// s.c, s.i, s.d}§
     940        m; n;                                                                   §\C{\color{red}// t.m, t.n}§
     941}
     942\end{cfa}
     943
     944In detail, the @with@ statement has the form:
     945\begin{cfa}
     946§\emph{with-statement}§:
     947        'with' '(' §\emph{expression-list}§ ')' §\emph{compound-statement}§
     948\end{cfa}
     949and may appear as the body of a function or nested within a function body.
     950Each expression in the expression-list provides a type and object.
     951The type must be an aggregate type.
     952(Enumerations are already opened.)
     953The object is the implicit qualifier for the open structure-fields.
     954
     955All expressions in the expression list are open in parallel within the compound statement.
     956This semantic is different from Pascal, which nests the openings from left to right.
     957The difference between parallel and nesting occurs for fields with the same name and type:
     958\begin{cfa}
     959struct S { int `i`; int j; double m; } s, w;
     960struct T { int `i`; int k; int m; } t, w;
     961with ( s, t ) {
     962        j + k;                                                                  §\C{// unambiguous, s.j + t.k}§
     963        m = 5.0;                                                                §\C{// unambiguous, t.m = 5.0}§
     964        m = 1;                                                                  §\C{// unambiguous, s.m = 1}§
     965        int a = m;                                                              §\C{// unambiguous, a = s.i }§
     966        double b = m;                                                   §\C{// unambiguous, b = t.m}§
     967        int c = s.i + t.i;                                              §\C{// unambiguous, qualification}§
     968        (double)m;                                                              §\C{// unambiguous, cast}§
     969}
     970\end{cfa}
     971For parallel semantics, both @s.i@ and @t.i@ are visible, so @i@ is ambiguous without qualification;
     972for nested semantics, @t.i@ hides @s.i@, so @i@ implies @t.i@.
     973\CFA's ability to overload variables means fields with the same name but different types are automatically disambiguated, eliminating most qualification when opening multiple aggregates.
     974Qualification or a cast is used to disambiguate.
     975
     976There is an interesting problem between parameters and the function-body @with@, \eg:
     977\begin{cfa}
     978void ?{}( S & s, int i ) with ( s ) {           §\C{// constructor}§
     979        `s.i = i;`  j = 3;  m = 5.5;                    §\C{// initialize fields}§
     980}
     981\end{cfa}
     982Here, the assignment @s.i = i@ means @s.i = s.i@, which is meaningless, and there is no mechanism to qualify the parameter @i@, making the assignment impossible using the function-body @with@.
     983To solve this problem, parameters are treated like an initialized aggregate:
     984\begin{cfa}
     985struct Params {
     986        S & s;
     987        int i;
     988} params;
     989\end{cfa}
     990and implicitly opened \emph{after} a function-body open, to give them higher priority:
     991\begin{cfa}
     992void ?{}( S & s, int `i` ) with ( s ) `with( §\emph{\color{red}params}§ )` {
     993        s.i = `i`; j = 3; m = 5.5;
     994}
     995\end{cfa}
     996Finally, a cast may be used to disambiguate among overload variables in a @with@ expression:
     997\begin{cfa}
     998with ( w ) { ... }                                                      §\C{// ambiguous, same name and no context}§
     999with ( (S)w ) { ... }                                           §\C{// unambiguous, cast}§
     1000\end{cfa}
     1001and @with@ expressions may be complex expressions with type reference (see Section~\ref{s:References}) to aggregate:
     1002% \begin{cfa}
     1003% struct S { int i, j; } sv;
     1004% with ( sv ) {                                                         §\C{// implicit reference}§
     1005%       S & sr = sv;
     1006%       with ( sr ) {                                                   §\C{// explicit reference}§
     1007%               S * sp = &sv;
     1008%               with ( *sp ) {                                          §\C{// computed reference}§
     1009%                       i = 3; j = 4;                                   §\C{\color{red}// sp--{\textgreater}i, sp--{\textgreater}j}§
     1010%               }
     1011%               i = 2; j = 3;                                           §\C{\color{red}// sr.i, sr.j}§
     1012%       }
     1013%       i = 1; j = 2;                                                   §\C{\color{red}// sv.i, sv.j}§
     1014% }
     1015% \end{cfa}
    9141016
    9151017In \Index{object-oriented} programming, there is an implicit first parameter, often names \textbf{©self©} or \textbf{©this©}, which is elided.
     
    9351037\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.
    9361038\begin{cfa}
    937 int mem( S & this ) ®with this® { §\C{// with clause}§
     1039int mem( S & this ) ®with( this )® { §\C{// with clause}§
    9381040        i = 1;                                          §\C{\color{red}// this.i}§
    9391041        j = 2;                                          §\C{\color{red}// this.j}§
     
    9431045\begin{cfa}
    9441046struct T { double m, n; };
    945 int mem2( S & this1, T & this2 ) ®with this1, this2® {
     1047int mem2( S & this1, T & this2 ) ®with( this1, this2 )® {
    9461048        i = 1; j = 2;
    9471049        m = 1.0; n = 2.0;
     
    9541056        struct S1 { ... } s1;
    9551057        struct S2 { ... } s2;
    956         ®with s1® {                                     §\C{// with statement}§
     1058        ®with( s1 )® {                          §\C{// with statement}§
    9571059                // access fields of s1 without qualification
    9581060                ®with s2® {                             §\C{// nesting}§
     
    9711073struct S { int i; int j; double m; } a, c;
    9721074struct T { int i; int k; int m } b, c;
    973 ®with a, b® {
    974         j + k;                                          §\C{// unambiguous, unique names define unique types}§
    975         i;                                                      §\C{// ambiguous, same name and type}§
    976         a.i + b.i;                                      §\C{// unambiguous, qualification defines unique names}§
    977         m;                                                      §\C{// ambiguous, same name and no context to define unique type}§
    978         m = 5.0;                                        §\C{// unambiguous, same name and context defines unique type}§
    979         m = 1;                                          §\C{// unambiguous, same name and context defines unique type}§
    980 }
    981 ®with c® { ... }                                §\C{// ambiguous, same name and no context}§
    982 ®with (S)c® { ... }                             §\C{// unambiguous, same name and cast defines unique type}§
    983 \end{cfa}
    984 
     1075with( a, b )
     1076{
     1077}
     1078\end{cfa}
     1079
     1080\begin{comment}
    9851081The components in the "with" clause
    9861082
     
    10071103the "with" to be implemented because I hate having to type all those object
    10081104names for fields. It's a great way to drive people away from the language.
     1105\end{comment}
    10091106
    10101107
     
    15951692
    15961693\item
    1597 lvalue to reference conversion: \lstinline[deletekeywords=lvalue]$lvalue-type cv1 T$ converts to ©cv2 T &©, which allows implicitly converting variables to references.
     1694lvalue to reference conversion: \lstinline[deletekeywords=lvalue]@lvalue-type cv1 T@ converts to ©cv2 T &©, which allows implicitly converting variables to references.
    15981695\begin{cfa}
    15991696int x, &r = ®x®, f( int & p ); // lvalue variable (int) convert to reference (int &)
     
    63616458
    63626459
     6460\section{Time}
     6461\label{s:TimeLib}
     6462
     6463
     6464%\subsection{\texorpdfstring{\protect\lstinline@Duration@}{Duration}}
     6465\subsection{\texorpdfstring{\LstKeywordStyle{\textmd{Duration}}}{Duration}}
     6466\label{s:Duration}
     6467
     6468\leavevmode
     6469\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6470struct Duration {
     6471        int64_t tv;                                                     §\C{// nanoseconds}§
     6472};
     6473
     6474void ?{}( Duration & dur );
     6475void ?{}( Duration & dur, zero_t );
     6476
     6477Duration ?=?( Duration & dur, zero_t );
     6478
     6479Duration +?( Duration rhs );
     6480Duration ?+?( Duration & lhs, Duration rhs );
     6481Duration ?+=?( Duration & lhs, Duration rhs );
     6482
     6483Duration -?( Duration rhs );
     6484Duration ?-?( Duration & lhs, Duration rhs );
     6485Duration ?-=?( Duration & lhs, Duration rhs );
     6486
     6487Duration ?*?( Duration lhs, int64_t rhs );
     6488Duration ?*?( int64_t lhs, Duration rhs );
     6489Duration ?*=?( Duration & lhs, int64_t rhs );
     6490
     6491int64_t ?/?( Duration lhs, Duration rhs );
     6492Duration ?/?( Duration lhs, int64_t rhs );
     6493Duration ?/=?( Duration & lhs, int64_t rhs );
     6494double div( Duration lhs, Duration rhs );
     6495
     6496Duration ?%?( Duration lhs, Duration rhs );
     6497Duration ?%=?( Duration & lhs, Duration rhs );
     6498
     6499_Bool ?==?( Duration lhs, Duration rhs );
     6500_Bool ?!=?( Duration lhs, Duration rhs );
     6501_Bool ?<? ( Duration lhs, Duration rhs );
     6502_Bool ?<=?( Duration lhs, Duration rhs );
     6503_Bool ?>? ( Duration lhs, Duration rhs );
     6504_Bool ?>=?( Duration lhs, Duration rhs );
     6505
     6506_Bool ?==?( Duration lhs, zero_t );
     6507_Bool ?!=?( Duration lhs, zero_t );
     6508_Bool ?<? ( Duration lhs, zero_t );
     6509_Bool ?<=?( Duration lhs, zero_t );
     6510_Bool ?>? ( Duration lhs, zero_t );
     6511_Bool ?>=?( Duration lhs, zero_t );
     6512
     6513Duration abs( Duration rhs );
     6514
     6515forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur );
     6516
     6517Duration ?`ns( int64_t nsec );
     6518Duration ?`us( int64_t usec );
     6519Duration ?`ms( int64_t msec );
     6520Duration ?`s( int64_t sec );
     6521Duration ?`s( double sec );
     6522Duration ?`m( int64_t min );
     6523Duration ?`m( double min );
     6524Duration ?`h( int64_t hours );
     6525Duration ?`h( double hours );
     6526Duration ?`d( int64_t days );
     6527Duration ?`d( double days );
     6528Duration ?`w( int64_t weeks );
     6529Duration ?`w( double weeks );
     6530
     6531int64_t ?`ns( Duration dur );
     6532int64_t ?`us( Duration dur );
     6533int64_t ?`ms( Duration dur );
     6534int64_t ?`s( Duration dur );
     6535int64_t ?`m( Duration dur );
     6536int64_t ?`h( Duration dur );
     6537int64_t ?`d( Duration dur );
     6538int64_t ?`w( Duration dur );
     6539\end{cfa}
     6540
     6541
     6542%\subsection{\texorpdfstring{\protect\lstinline@\timeval@}{timeval}}
     6543\subsection{\texorpdfstring{\LstKeywordStyle{\textmd{timeval}}}{timeval}}
     6544\label{s:timeval}
     6545
     6546\leavevmode
     6547\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6548void ?{}( timeval & t );
     6549void ?{}( timeval & t, time_t sec, suseconds_t usec );
     6550void ?{}( timeval & t, time_t sec );
     6551void ?{}( timeval & t, zero_t );
     6552void ?{}( timeval & t, Time time );
     6553
     6554timeval ?=?( timeval & t, zero_t );
     6555timeval ?+?( timeval & lhs, timeval rhs );
     6556timeval ?-?( timeval & lhs, timeval rhs );
     6557_Bool ?==?( timeval lhs, timeval rhs );
     6558_Bool ?!=?( timeval lhs, timeval rhs );
     6559\end{cfa}
     6560
     6561
     6562\subsection{\texorpdfstring{\protect\lstinline@timespec@}{timespec}}
     6563\label{s:timespec}
     6564
     6565\leavevmode
     6566\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6567void ?{}( timespec & t );
     6568void ?{}( timespec & t, time_t sec, __syscall_slong_t nsec );
     6569void ?{}( timespec & t, time_t sec );
     6570void ?{}( timespec & t, zero_t );
     6571void ?{}( timespec & t, Time time );
     6572
     6573timespec ?=?( timespec & t, zero_t );
     6574timespec ?+?( timespec & lhs, timespec rhs );
     6575timespec ?-?( timespec & lhs, timespec rhs );
     6576_Bool ?==?( timespec lhs, timespec rhs );
     6577_Bool ?!=?( timespec lhs, timespec rhs );
     6578\end{cfa}
     6579
     6580
     6581\subsection{\texorpdfstring{\protect\lstinline@itimerval@}{itimerval}}
     6582\label{s:itimerval}
     6583
     6584\leavevmode
     6585\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6586void ?{}( itimerval & itv, Duration alarm );
     6587void ?{}( itimerval & itv, Duration alarm, Duration interval );
     6588\end{cfa}
     6589
     6590
     6591\subsection{\texorpdfstring{\protect\lstinline@Time@}{Time}}
     6592\label{s:Time}
     6593
     6594\leavevmode
     6595\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6596struct Time {
     6597        uint64_t tv;                                            §\C{// nanoseconds since UNIX epoch}§
     6598};
     6599
     6600void ?{}( Time & time );
     6601void ?{}( Time & time, zero_t );
     6602void ?{}( Time & time, int year, int month = 0, int day = 0, int hour = 0, int min = 0, int sec = 0, int nsec = 0 );
     6603Time ?=?( Time & time, zero_t );
     6604
     6605void ?{}( Time & time, timeval t );
     6606Time ?=?( Time & time, timeval t );
     6607
     6608void ?{}( Time & time, timespec t );
     6609Time ?=?( Time & time, timespec t );
     6610
     6611Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tv + rhs.tv }; }
     6612Time ?+?( Duration lhs, Time rhs ) { return rhs + lhs; }
     6613Time ?+=?( Time & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; }
     6614
     6615Duration ?-?( Time lhs, Time rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
     6616Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.tv - rhs.tv }; }
     6617Time ?-=?( Time & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
     6618_Bool ?==?( Time lhs, Time rhs ) { return lhs.tv == rhs.tv; }
     6619_Bool ?!=?( Time lhs, Time rhs ) { return lhs.tv != rhs.tv; }
     6620_Bool ?<?( Time lhs, Time rhs ) { return lhs.tv < rhs.tv; }
     6621_Bool ?<=?( Time lhs, Time rhs ) { return lhs.tv <= rhs.tv; }
     6622_Bool ?>?( Time lhs, Time rhs ) { return lhs.tv > rhs.tv; }
     6623_Bool ?>=?( Time lhs, Time rhs ) { return lhs.tv >= rhs.tv; }
     6624
     6625forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );
     6626
     6627char * yy_mm_dd( Time time, char * buf );
     6628char * ?`ymd( Time time, char * buf ) { // short form
     6629        return yy_mm_dd( time, buf );
     6630} // ymd
     6631
     6632char * mm_dd_yy( Time time, char * buf );
     6633char * ?`mdy( Time time, char * buf ) { // short form
     6634        return mm_dd_yy( time, buf );
     6635} // mdy
     6636
     6637char * dd_mm_yy( Time time, char * buf );
     6638char * ?`dmy( Time time, char * buf ) { // short form
     6639        return dd_mm_yy( time, buf );;
     6640} // dmy
     6641
     6642size_t strftime( char * buf, size_t size, const char * fmt, Time time );
     6643\end{cfa}
     6644
     6645
     6646\section{Clock}
     6647
     6648\subsection{C time}
     6649\label{s:Ctime}
     6650
     6651\leavevmode
     6652\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6653char * ctime( time_t tp );
     6654char * ctime_r( time_t tp, char * buf );
     6655tm * gmtime( time_t tp );
     6656tm * gmtime_r( time_t tp, tm * result );
     6657tm * localtime( time_t tp );
     6658tm * localtime_r( time_t tp, tm * result );
     6659\end{cfa}
     6660
     6661
     6662%\subsection{\texorpdfstring{\protect\lstinline@Clock@}{Clock}}
     6663\subsection{\texorpdfstring{\LstKeywordStyle{\textmd{Clock}}}{Clock}}
     6664\label{s:Clock}
     6665
     6666\leavevmode
     6667\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6668struct Clock {
     6669        Duration offset;                                        §\C{// for virtual clock: contains offset from real-time}§
     6670        int clocktype;                                          §\C{// implementation only -1 (virtual), CLOCK\_REALTIME}§
     6671};
     6672
     6673void resetClock( Clock & clk );
     6674void resetClock( Clock & clk, Duration adj );
     6675void ?{}( Clock & clk );
     6676void ?{}( Clock & clk, Duration adj );
     6677Duration getRes();
     6678Time getTimeNsec();                                             §\C{// with nanoseconds}§
     6679Time getTime();                                                 §\C{// without nanoseconds}§
     6680Time getTime( Clock & clk );
     6681Time ?()( Clock & clk );
     6682timeval getTime( Clock & clk );
     6683tm getTime( Clock & clk );
     6684\end{cfa}
     6685
     6686
    63636687\section{Multi-precision Integers}
    63646688\label{s:MultiPrecisionIntegers}
     
    66586982\end{cfa}
    66596983
    6660 
    66616984\bibliographystyle{plain}
    66626985\bibliography{pl}
  • src/CodeGen/CodeGenerator.cc

    r2efe4b8 r1cdfa82  
    116116        }
    117117
    118         CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks ) : indent( CodeGenerator::tabsize ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ), endl( *this ) {}
     118        CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks, bool printExprTypes ) : indent( CodeGenerator::tabsize ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ), printExprTypes( printExprTypes ), endl( *this ) {}
    119119
    120120        string CodeGenerator::mangleName( DeclarationWithType * decl ) {
     
    159159        }
    160160
     161        // *** Expression
     162        void CodeGenerator::previsit( Expression * node ) {
     163                previsit( (BaseSyntaxNode *)node );
     164                GuardAction( [this, node](){
     165                        if ( printExprTypes ) {
     166                                output << " /* " << genType( node->result, "", pretty, genC ) << " */ ";
     167                        }
     168                } );
     169        }
     170
    161171        // *** Declarations
    162172        void CodeGenerator::postvisit( FunctionDecl * functionDecl ) {
     
    203213
    204214        void CodeGenerator::handleAggregate( AggregateDecl * aggDecl, const std::string & kind ) {
    205                 genAttributes( aggDecl->get_attributes() );
    206 
    207215                if( ! aggDecl->get_parameters().empty() && ! genC ) {
    208216                        // assertf( ! genC, "Aggregate type parameters should not reach code generation." );
     
    213221                }
    214222
    215                 output << kind << aggDecl->get_name();
     223                output << kind;
     224                genAttributes( aggDecl->get_attributes() );
     225                output << aggDecl->get_name();
    216226
    217227                if ( aggDecl->has_body() ) {
     
    298308                        output << " }";
    299309                }
     310        }
     311
     312        void CodeGenerator::postvisit( StaticAssertDecl * assertDecl ) {
     313                output << "_Static_assert(";
     314                assertDecl->condition->accept( *visitor );
     315                output << ", ";
     316                assertDecl->message->accept( *visitor );
     317                output << ")";
    300318        }
    301319
     
    578596                        output << ")";
    579597                } // if
    580                 castExpr->get_arg()->accept( *visitor );
     598                castExpr->arg->accept( *visitor );
     599                output << ")";
     600        }
     601
     602        void CodeGenerator::postvisit( KeywordCastExpr * castExpr ) {
     603                assertf( ! genC, "KeywordCast should not reach code generation." );
     604                extension( castExpr );
     605                output << "((" << castExpr->targetString() << " &)";
     606                castExpr->arg->accept( *visitor );
    581607                output << ")";
    582608        }
     
    928954                        output << "continue";
    929955                        break;
     956                  case BranchStmt::FallThrough:
     957                  case BranchStmt::FallThroughDefault:
     958                        assertf( ! genC, "fallthru should not reach code generation." );
     959                  output << "fallthru";
     960                        break;
    930961                } // switch
     962                // print branch target for labelled break/continue/fallthru in debug mode
     963                if ( ! genC && branchStmt->get_type() != BranchStmt::Goto ) {
     964                        if ( ! branchStmt->get_target().empty() ) {
     965                                output << " " << branchStmt->get_target();
     966                        } else if ( branchStmt->get_type() == BranchStmt::FallThrough ) {
     967                                output << " default";
     968                        }
     969                }
    931970                output << ";";
    932971        }
  • src/CodeGen/CodeGenerator.h

    r2efe4b8 r1cdfa82  
    2727
    2828namespace CodeGen {
    29         struct CodeGenerator : public WithShortCircuiting, public WithVisitorRef<CodeGenerator> {
     29        struct CodeGenerator : public WithShortCircuiting, public WithGuards, public WithVisitorRef<CodeGenerator> {
    3030          static int tabsize;
    3131
    32                 CodeGenerator( std::ostream &os, bool pretty = false, bool genC = false, bool lineMarks = false );
     32                CodeGenerator( std::ostream &os, bool pretty = false, bool genC = false, bool lineMarks = false, bool printExprTypes = false );
    3333
    3434                //*** Turn off visit_children for all nodes
     
    3838                void postvisit( BaseSyntaxNode * );
    3939
     40                //*** print type for all expressions
     41                void previsit( Expression * node );
     42
    4043                //*** Declaration
    4144                void postvisit( StructDecl * );
    4245                void postvisit( FunctionDecl * );
    4346                void postvisit( ObjectDecl * );
    44                 void postvisit( UnionDecl *aggregateDecl );
    45                 void postvisit( EnumDecl *aggregateDecl );
    46                 void postvisit( TraitDecl *aggregateDecl );
    47                 void postvisit( TypedefDecl *typeDecl );
    48                 void postvisit( TypeDecl *typeDecl );
     47                void postvisit( UnionDecl * aggregateDecl );
     48                void postvisit( EnumDecl * aggregateDecl );
     49                void postvisit( TraitDecl * aggregateDecl );
     50                void postvisit( TypedefDecl * typeDecl );
     51                void postvisit( TypeDecl * typeDecl );
     52                void postvisit( StaticAssertDecl * assertDecl );
    4953
    5054                //*** Initializer
     
    6569                void postvisit( LabelAddressExpr *addressExpr );
    6670                void postvisit( CastExpr *castExpr );
     71                void postvisit( KeywordCastExpr * castExpr );
    6772                void postvisit( VirtualCastExpr *castExpr );
    6873                void postvisit( UntypedMemberExpr *memberExpr );
     
    139144                bool genC = false;    // true if output has to be C code
    140145                bool lineMarks = false;
     146                bool printExprTypes = false;
    141147        public:
    142148                LineEnder endl;
  • src/CodeGen/GenType.cc

    r2efe4b8 r1cdfa82  
    4848                void postvisit( ZeroType * zeroType );
    4949                void postvisit( OneType * oneType );
     50                void postvisit( TraitInstType * inst );
     51                void postvisit( TypeofType * typeof );
    5052
    5153          private:
     
    289291        }
    290292
     293        void GenType::postvisit( TraitInstType * inst ) {
     294                assertf( ! genC, "Trait types should not reach code generation." );
     295                typeString = inst->name + " " + typeString;
     296                handleQualifiers( inst );
     297        }
     298
     299        void GenType::postvisit( TypeofType * typeof ) {
     300                std::ostringstream os;
     301                PassVisitor<CodeGenerator> cg( os, pretty, genC, lineMarks );
     302                os << "typeof(";
     303                typeof->expr->accept( cg );
     304                os << ") " << typeString;
     305                typeString = os.str();
     306                handleQualifiers( typeof );
     307        }
     308
    291309        void GenType::handleQualifiers( Type * type ) {
    292310                if ( type->get_const() ) {
  • src/CodeGen/Generate.cc

    r2efe4b8 r1cdfa82  
    4646        } // namespace
    4747
    48         void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC, bool lineMarks ) {
     48        void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC, bool lineMarks, bool printExprTypes ) {
    4949                cleanTree( translationUnit );
    5050
    51                 PassVisitor<CodeGenerator> cgv( os, pretty, generateC, lineMarks );
     51                PassVisitor<CodeGenerator> cgv( os, pretty, generateC, lineMarks, printExprTypes );
    5252                for ( auto & dcl : translationUnit ) {
    5353                        if ( LinkageSpec::isGeneratable( dcl->get_linkage() ) && (doIntrinsics || ! LinkageSpec::isBuiltin( dcl->get_linkage() ) ) ) {
     
    6666                        os << CodeGen::genPrettyType( type, "" );
    6767                } else {
    68                         PassVisitor<CodeGenerator> cgv( os, true, false, false );
     68                        PassVisitor<CodeGenerator> cgv( os, true, false, false, false );
    6969                        node->accept( cgv );
    7070                }
  • src/CodeGen/Generate.h

    r2efe4b8 r1cdfa82  
    2424namespace CodeGen {
    2525        /// Generates code. doIntrinsics determines if intrinsic functions are printed, pretty formats output nicely (e.g., uses unmangled names, etc.), generateC is true when the output must consist only of C code (allows some assertions, etc.)
    26         void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC = false , bool lineMarks = false );
     26        void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC = false , bool lineMarks = false, bool printTypeExpr = false );
    2727
    2828        /// Generate code for a single node -- helpful for debugging in gdb
  • src/CodeGen/OperatorTable.cc

    r2efe4b8 r1cdfa82  
    7979        } // namespace
    8080
    81         bool operatorLookup( std::string funcName, OperatorInfo &info ) {
     81        bool operatorLookup( const std::string & funcName, OperatorInfo & info ) {
    8282                static bool init = false;
    8383                if ( ! init ) {
     
    100100                        return true;
    101101                } // if
     102        }
     103
     104        bool isOperator( const std::string & funcName ) {
     105                OperatorInfo info;
     106                return operatorLookup( funcName, info );
    102107        }
    103108
  • src/CodeGen/OperatorTable.h

    r2efe4b8 r1cdfa82  
    4141        };
    4242
    43         bool operatorLookup( std::string funcName, OperatorInfo &info );
     43        bool isOperator( const std::string & funcName );
     44        bool operatorLookup( const std::string & funcName, OperatorInfo & info );
    4445
    4546        bool isConstructor( const std::string & );
  • src/Common/Debug.h

    r2efe4b8 r1cdfa82  
    2828namespace Debug {
    2929        /// debug codegen a translation unit
    30         static inline void codeGen( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label ) {
     30        static inline void codeGen( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label, __attribute__((unused)) LinkageSpec::Spec linkageFilter = LinkageSpec::Compiler ) {
    3131        #ifdef DEBUG
    3232                std::list< Declaration * > decls;
    3333
    34                 filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), []( Declaration * decl ) {
    35                         return ! LinkageSpec::isBuiltin( decl->get_linkage() );
     34                filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), [linkageFilter]( Declaration * decl ) {
     35                        return ! (decl->linkage & linkageFilter);
    3636                });
    3737
    3838                std::cerr << "======" << label << "======" << std::endl;
    39                 CodeGen::generate( decls, std::cerr, false, true );
     39                CodeGen::generate(
     40                        decls,
     41                        std::cerr,
     42                        true /* doIntrinsics */,
     43                        true /* pretty */,
     44                        false /* generateC */,
     45                        false /* lineMarks */,
     46                        true /* printTypeExpr */
     47                );
    4048        #endif
    4149        } // dump
    4250
    43         static inline void treeDump( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label ) {
     51        static inline void treeDump( __attribute__((unused)) const std::list< Declaration * > & translationUnit, __attribute__((unused)) const std::string & label, __attribute__((unused)) LinkageSpec::Spec linkageFilter = LinkageSpec::Compiler ) {
    4452        #ifdef DEBUG
    4553                std::list< Declaration * > decls;
    4654
    47                 filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), []( Declaration * decl ) {
    48                         return ! LinkageSpec::isBuiltin( decl->get_linkage() );
     55                filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), [linkageFilter]( Declaration * decl ) {
     56                        return ! (decl->linkage & linkageFilter);
    4957                });
    5058
  • src/Common/ErrorObjects.h

    r2efe4b8 r1cdfa82  
    3535class SemanticErrorException : public std::exception {
    3636  public:
    37         SemanticErrorException() = default;
     37        SemanticErrorException() = default;
    3838        SemanticErrorException( CodeLocation location, std::string error );
    3939        ~SemanticErrorException() throw() {}
  • src/Common/PassVisitor.h

    r2efe4b8 r1cdfa82  
    6666        virtual void visit( TypedefDecl * typeDecl ) override final;
    6767        virtual void visit( AsmDecl * asmDecl ) override final;
     68        virtual void visit( StaticAssertDecl * assertDecl ) override final;
    6869
    6970        virtual void visit( CompoundStmt * compoundStmt ) override final;
     
    9192        virtual void visit( NameExpr * nameExpr ) override final;
    9293        virtual void visit( CastExpr * castExpr ) override final;
     94        virtual void visit( KeywordCastExpr * castExpr ) override final;
    9395        virtual void visit( VirtualCastExpr * castExpr ) override final;
    9496        virtual void visit( AddressExpr * addressExpr ) override final;
     
    163165        virtual Declaration * mutate( TypedefDecl * typeDecl ) override final;
    164166        virtual AsmDecl * mutate( AsmDecl * asmDecl ) override final;
     167        virtual StaticAssertDecl * mutate( StaticAssertDecl * assertDecl ) override final;
    165168
    166169        virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ) override final;
     
    187190        virtual Expression * mutate( UntypedExpr * untypedExpr ) override final;
    188191        virtual Expression * mutate( NameExpr * nameExpr ) override final;
    189         virtual Expression * mutate( AddressExpr * castExpr ) override final;
     192        virtual Expression * mutate( AddressExpr * addrExpr ) override final;
    190193        virtual Expression * mutate( LabelAddressExpr * labAddressExpr ) override final;
    191194        virtual Expression * mutate( CastExpr * castExpr ) override final;
     195        virtual Expression * mutate( KeywordCastExpr * castExpr ) override final;
    192196        virtual Expression * mutate( VirtualCastExpr * castExpr ) override final;
    193197        virtual Expression * mutate( UntypedMemberExpr * memberExpr ) override final;
  • src/Common/PassVisitor.impl.h

    r2efe4b8 r1cdfa82  
    685685
    686686//--------------------------------------------------------------------------
     687// StaticAssertDecl
     688template< typename pass_type >
     689void PassVisitor< pass_type >::visit( StaticAssertDecl * node ) {
     690        VISIT_START( node );
     691
     692        maybeAccept_impl( node->condition, *this );
     693        maybeAccept_impl( node->message  , *this );
     694
     695        VISIT_END( node );
     696}
     697
     698template< typename pass_type >
     699StaticAssertDecl * PassVisitor< pass_type >::mutate( StaticAssertDecl * node ) {
     700        MUTATE_START( node );
     701
     702        maybeMutate_impl( node->condition, *this );
     703        maybeMutate_impl( node->message  , *this );
     704
     705        MUTATE_END( StaticAssertDecl, node );
     706}
     707
     708//--------------------------------------------------------------------------
    687709// CompoundStmt
    688710template< typename pass_type >
     
    12381260
    12391261//--------------------------------------------------------------------------
     1262// KeywordCastExpr
     1263template< typename pass_type >
     1264void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) {
     1265        VISIT_START( node );
     1266
     1267        indexerScopedAccept( node->result, *this );
     1268        maybeAccept_impl        ( node->arg   , *this );
     1269
     1270        VISIT_END( node );
     1271}
     1272
     1273template< typename pass_type >
     1274Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) {
     1275        MUTATE_START( node );
     1276
     1277        indexerScopedMutate( node->env   , *this );
     1278        indexerScopedMutate( node->result, *this );
     1279        maybeMutate_impl   ( node->arg   , *this );
     1280
     1281        MUTATE_END( Expression, node );
     1282}
     1283
     1284//--------------------------------------------------------------------------
    12401285// VirtualCastExpr
    12411286template< typename pass_type >
     
    14911536        indexerScopedAccept( node->result, *this );
    14921537        maybeAccept_impl   ( node->type  , *this );
    1493         maybeAccept_impl   ( node->member, *this );
    14941538
    14951539        VISIT_END( node );
     
    15031547        indexerScopedMutate( node->result, *this );
    15041548        maybeMutate_impl   ( node->type  , *this );
    1505         maybeMutate_impl   ( node->member, *this );
    15061549
    15071550        MUTATE_END( Expression, node );
  • src/Common/SemanticError.cc

    r2efe4b8 r1cdfa82  
    6868}
    6969
    70 void SemanticWarningImpl( CodeLocation location, Warning, const char * const fmt, ... ) {
    71         va_list args;
    72         va_start(args, fmt);
    73         std::string msg = fmtToString( fmt, args );
    74         va_end(args);
    75         std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl;
     70void SemanticWarningImpl( CodeLocation location, Warning warning, const char * const fmt, ... ) {
     71        Severity severity = WarningFormats[(int)warning].severity;
     72        switch(severity) {
     73        case Severity::Suppress :
     74                break;
     75        case Severity::Warn :
     76                {
     77                        va_list args;
     78                        va_start(args, fmt);
     79                        std::string msg = fmtToString( fmt, args );
     80                        va_end(args);
     81                        std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl;
     82                }
     83                break;
     84        case Severity::Error :
     85                {
     86                        va_list args;
     87                        va_start(args, fmt);
     88                        std::string msg = fmtToString( fmt, args );
     89                        va_end(args);
     90                        SemanticError(location, msg);
     91                }
     92                break;
     93        case Severity::Critical :
     94                assertf(false, "Critical errors not implemented yet");
     95                break;
     96        }
    7697}
    7798
  • src/Common/SemanticError.h

    r2efe4b8 r1cdfa82  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 29 22:03:36 2017
    13 // Update Count     : 17
     12// Last Modified On : Thu Apr 19 17:52:03 2018
     13// Update Count     : 19
    1414//
    1515
     
    3636// Warnings
    3737
    38 constexpr const char * const WarningFormats[] = {
    39         "self assignment of expression: %s",
     38enum class Severity {
     39        Suppress,
     40        Warn,
     41        Error,
     42        Critical
     43};
     44
     45struct WarningData {
     46        const char * const name;
     47        const char * const message;
     48        mutable Severity severity;
     49};
     50
     51constexpr const WarningData WarningFormats[] = {
     52        {"self-assign"         , "self assignment of expression: %s"           , Severity::Warn},
     53        {"reference-conversion", "rvalue to reference conversion of rvalue: %s", Severity::Warn},
     54        {"qualifiers-zero_t-one_t", "questionable use of type qualifier %s with %s", Severity::Warn},
    4055};
    4156
    4257enum class Warning {
    4358        SelfAssignment,
     59        RvalueToReferenceConversion,
     60        BadQualifiersZeroOne,
    4461        NUMBER_OF_WARNINGS, //This MUST be the last warning
    4562};
     
    5067);
    5168
    52 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id], __VA_ARGS__)
     69#define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id].message, __VA_ARGS__)
    5370
    5471void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4)));
  • src/Common/utility.h

    r2efe4b8 r1cdfa82  
    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 17 11:38:00 2017
    13 // Update Count     : 34
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Apr 20 22:35:33 2018
     13// Update Count     : 38
    1414//
    1515
     
    433433}
    434434
     435// -----------------------------------------------------------------------------
     436// O(1) polymorphic integer ilog2, using clz, which returns the number of leading 0-bits, starting at the most
     437// significant bit (single instruction on x86)
     438
     439template<typename T>
     440inline constexpr T ilog2(const T & t) {
     441        if ( std::is_integral<T>::value ) {
     442                const constexpr int r = sizeof(t) * __CHAR_BIT__ - 1;
     443                if ( sizeof(T) == sizeof(unsigned int ) ) return r - __builtin_clz( t );
     444                if ( sizeof(T) == sizeof(unsigned long) ) return r - __builtin_clzl( t );
     445                if ( sizeof(T) == sizeof(unsigned long long) ) return r - __builtin_clzll( t );
     446        } // if
     447        return -1;
     448} // ilong2
    435449
    436450
  • src/Concurrency/Keywords.cc

    r2efe4b8 r1cdfa82  
    5454          public:
    5555
    56                 ConcurrentSueKeyword( std::string&& type_name, std::string&& field_name, std::string&& getter_name, std::string&& context_error, bool needs_main ) :
    57                   type_name( type_name ), field_name( field_name ), getter_name( getter_name ), context_error( context_error ), needs_main( needs_main ) {}
     56                ConcurrentSueKeyword( std::string&& type_name, std::string&& field_name, std::string&& getter_name, std::string&& context_error, bool needs_main, KeywordCastExpr::Target cast_target ) :
     57                  type_name( type_name ), field_name( field_name ), getter_name( getter_name ), context_error( context_error ), needs_main( needs_main ), cast_target( cast_target ) {}
    5858
    5959                virtual ~ConcurrentSueKeyword() {}
    6060
    61                 void postvisit( StructDecl * decl );
     61                Declaration * postmutate( StructDecl * decl );
    6262
    6363                void handle( StructDecl * );
     
    6767
    6868                virtual bool is_target( StructDecl * decl ) = 0;
     69
     70                Expression * postmutate( KeywordCastExpr * cast );
    6971
    7072          private:
     
    7476                const std::string context_error;
    7577                bool needs_main;
     78                KeywordCastExpr::Target cast_target;
    7679
    7780                StructDecl* type_decl = nullptr;
     
    9699                        "get_thread",
    97100                        "thread keyword requires threads to be in scope, add #include <thread>",
    98                         true
     101                        true,
     102                        KeywordCastExpr::Thread
    99103                )
    100104                {}
     
    106110                static void implement( std::list< Declaration * > & translationUnit ) {
    107111                        PassVisitor< ThreadKeyword > impl;
    108                         acceptAll( translationUnit, impl );
     112                        mutateAll( translationUnit, impl );
    109113                }
    110114        };
     
    127131                        "get_coroutine",
    128132                        "coroutine keyword requires coroutines to be in scope, add #include <coroutine>",
    129                         true
     133                        true,
     134                        KeywordCastExpr::Coroutine
    130135                )
    131136                {}
     
    137142                static void implement( std::list< Declaration * > & translationUnit ) {
    138143                        PassVisitor< CoroutineKeyword > impl;
    139                         acceptAll( translationUnit, impl );
     144                        mutateAll( translationUnit, impl );
    140145                }
    141146        };
     
    158163                        "get_monitor",
    159164                        "monitor keyword requires monitors to be in scope, add #include <monitor>",
    160                         false
     165                        false,
     166                        KeywordCastExpr::Monitor
    161167                )
    162168                {}
     
    168174                static void implement( std::list< Declaration * > & translationUnit ) {
    169175                        PassVisitor< MonitorKeyword > impl;
    170                         acceptAll( translationUnit, impl );
     176                        mutateAll( translationUnit, impl );
    171177                }
    172178        };
     
    263269        }
    264270
    265         void ConcurrentSueKeyword::postvisit(StructDecl * decl) {
     271        Declaration * ConcurrentSueKeyword::postmutate(StructDecl * decl) {
    266272                if( decl->name == type_name && decl->body ) {
    267273                        assert( !type_decl );
     
    271277                        handle( decl );
    272278                }
    273         }
     279                return decl;
     280        }
     281
     282        Expression * ConcurrentSueKeyword::postmutate( KeywordCastExpr * cast ) {
     283                if ( cast_target == cast->target ) {
     284                        // convert (thread &)t to (thread_desc &)*get_thread(t), etc.
     285                        if( !type_decl ) SemanticError( cast, context_error );
     286                        Expression * arg = cast->arg;
     287                        cast->arg = nullptr;
     288                        delete cast;
     289                        return new CastExpr(
     290                                UntypedExpr::createDeref(
     291                                        new UntypedExpr( new NameExpr( getter_name ), { arg } )
     292                                ),
     293                                new ReferenceType(
     294                                        noQualifiers,
     295                                        new StructInstType( noQualifiers, type_decl ) )
     296                                );
     297                }
     298                return cast;
     299        }
     300
    274301
    275302        void ConcurrentSueKeyword::handle( StructDecl * decl ) {
  • src/ControlStruct/ExceptTranslate.cc

    r2efe4b8 r1cdfa82  
    3434#include "SynTree/Statement.h"        // for CompoundStmt, CatchStmt, ThrowStmt
    3535#include "SynTree/Type.h"             // for FunctionType, Type, noQualifiers
    36 #include "SynTree/VarExprReplacer.h"  // for VarExprReplacer, VarExprReplace...
     36#include "SynTree/DeclReplacer.h"     // for DeclReplacer
    3737#include "SynTree/Visitor.h"          // for acceptAll
    3838
     
    311311                        // Update variables in the body to point to this local copy.
    312312                        {
    313                                 VarExprReplacer::DeclMap mapping;
     313                                DeclReplacer::DeclMap mapping;
    314314                                mapping[ handler_decl ] = local_except;
    315                                 VarExprReplacer::replace( handler->body, mapping );
     315                                DeclReplacer::replace( handler->body, mapping );
    316316                        }
    317317
  • src/ControlStruct/MLEMutator.cc

    r2efe4b8 r1cdfa82  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:21:32 2016
    13 // Update Count     : 202
     12// Last Modified On : Thu Mar  8 17:08:25 2018
     13// Update Count     : 219
    1414//
    1515
     
    3838        }
    3939        namespace {
    40                 Statement * isLoop( Statement * stmt ) { return dynamic_cast< WhileStmt * >( stmt ) ? stmt : dynamic_cast< ForStmt * >( stmt ) ? stmt : 0; }
    41         }
     40                bool isLoop( const MLEMutator::Entry & e ) { return dynamic_cast< WhileStmt * >( e.get_controlStructure() ) || dynamic_cast< ForStmt * >( e.get_controlStructure() ); }
     41                bool isSwitch( const MLEMutator::Entry & e ) { return dynamic_cast< SwitchStmt *>( e.get_controlStructure() ); }
     42
     43                bool isBreakTarget( const MLEMutator::Entry & e ) { return isLoop( e ) || isSwitch( e ) || dynamic_cast< CompoundStmt *>( e.get_controlStructure() ); }
     44                bool isContinueTarget( const MLEMutator::Entry & e ) { return isLoop( e ); }
     45                bool isFallthroughTarget( const MLEMutator::Entry & e ) { return dynamic_cast< CaseStmt *>( e.get_controlStructure() );; }
     46                bool isFallthroughDefaultTarget( const MLEMutator::Entry & e ) { return isSwitch( e ); }
     47        } // namespace
    4248
    4349        // break labels have to come after the statement they break out of, so mutate a statement, then if they inform us
    4450        // through the breakLabel field tha they need a place to jump to on a break statement, add the break label to the
    4551        // body of statements
    46         void MLEMutator::fixBlock( std::list< Statement * > &kids ) {
     52        void MLEMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
     53                SemanticErrorException errors;
     54
    4755                for ( std::list< Statement * >::iterator k = kids.begin(); k != kids.end(); k++ ) {
    48                         *k = (*k)->acceptMutator(*visitor);
     56                        if ( caseClause ) {
     57                                // once a label is seen, it's no longer a valid fallthrough target
     58                                for ( Label & l : (*k)->labels ) {
     59                                        fallthroughLabels.erase( l );
     60                                }
     61                        }
     62
     63                        // aggregate errors since the PassVisitor mutate loop was unrollled
     64                        try {
     65                                *k = (*k)->acceptMutator(*visitor);
     66                        } catch( SemanticErrorException &e ) {
     67                                errors.append( e );
     68                        }
    4969
    5070                        if ( ! get_breakLabel().empty() ) {
     
    5575                        } // if
    5676                } // for
     77
     78                if ( ! errors.isEmpty() ) {
     79                        throw errors;
     80                }
    5781        }
    5882
     
    6387                        Label brkLabel = generator->newLabel("blockBreak", cmpndStmt);
    6488                        enclosingControlStructures.push_back( Entry( cmpndStmt, brkLabel ) );
     89                        GuardAction( [this]() { enclosingControlStructures.pop_back(); } );
    6590                } // if
    6691
     
    7499                                set_breakLabel( enclosingControlStructures.back().useBreakExit() );
    75100                        } // if
    76                         enclosingControlStructures.pop_back();
    77101                } // if
    78102        }
     
    112136                                        if ( isContinue ) {
    113137                                                // continue target is outermost loop
    114                                                 targetEntry = std::find_if( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), [](Entry &e) { return isLoop( e.get_controlStructure() ); } );
     138                                                targetEntry = std::find_if( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), isContinueTarget );
    115139                                        } else {
    116                                                 // break target is outmost control structure
    117                                                 if ( enclosingControlStructures.empty() ) SemanticError( branchStmt->location, "'break' outside a loop, switch, or labelled block" );
    118                                                 targetEntry = enclosingControlStructures.rbegin();
     140                                                // break target is outermost loop, switch, or block control structure
     141                                                if ( enclosingControlStructures.empty() ) SemanticError( branchStmt->location, "'break' outside a loop, 'switch', or labelled block" );
     142                                                targetEntry = std::find_if( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), isBreakTarget );
    119143                                        } // if
    120144                                } else {
     
    123147                                } // if
    124148                                // ensure that selected target is valid
    125                                 if ( targetEntry == enclosingControlStructures.rend() || (isContinue && ! isLoop( targetEntry->get_controlStructure() ) ) ) {
     149                                if ( targetEntry == enclosingControlStructures.rend() || (isContinue && ! isContinueTarget( *targetEntry ) ) ) {
    126150                                        SemanticError( branchStmt->location, toString( (isContinue ? "'continue'" : "'break'"), " target must be an enclosing ", (isContinue ? "loop: " : "control structure: "), originalTarget ) );
    127151                                } // if
    128152                                break;
    129153                        }
     154                        case BranchStmt::FallThrough:
     155                                targetEntry = std::find_if( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), isFallthroughTarget );
     156                                // ensure that selected target is valid
     157                                if ( targetEntry == enclosingControlStructures.rend() ) {
     158                                        SemanticError( branchStmt->location, "'fallthrough' must be enclosed in a 'switch' or 'choose'" );
     159                                } // if
     160                                if ( branchStmt->get_target() != "" ) {
     161                                        // labelled fallthrough
     162                                        // target must be in the set of valid fallthrough labels
     163                                        if ( ! fallthroughLabels.count( branchStmt->get_target() ) ) {
     164                                                SemanticError( branchStmt->location, toString( "'fallthrough' target must be a later case statement: ", originalTarget ) );
     165                                        }
     166                                        return new BranchStmt( originalTarget, BranchStmt::Goto );
     167                                }
     168                                break;
     169                        case BranchStmt::FallThroughDefault: {
     170                                // fallthrough default
     171                                targetEntry = std::find_if( enclosingControlStructures.rbegin(), enclosingControlStructures.rend(), isFallthroughDefaultTarget );
     172
     173                                // ensure that fallthrough is within a switch or choose
     174                                if ( targetEntry == enclosingControlStructures.rend() ) {
     175                                        SemanticError( branchStmt->location, "'fallthrough' must be enclosed in a 'switch' or 'choose'" );
     176                                } // if
     177
     178                                // ensure that switch or choose has a default clause
     179                                SwitchStmt * switchStmt = strict_dynamic_cast< SwitchStmt * >( targetEntry->get_controlStructure() );
     180                                bool foundDefault = false;
     181                                for ( Statement * stmt : switchStmt->statements ) {
     182                                        CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt );
     183                                        if ( caseStmt->isDefault() ) {
     184                                                foundDefault = true;
     185                                        } // if
     186                                } // for
     187                                if ( ! foundDefault ) {
     188                                        SemanticError( branchStmt->location, "'fallthrough default' must be enclosed in a 'switch' or 'choose' control structure with a 'default' clause" );
     189                                }
     190                                break;
     191                        }
     192
    130193                        default:
    131194                                assert( false );
     
    142205                                assert( targetEntry->useContExit() != "");
    143206                                exitLabel = targetEntry->useContExit();
     207                                break;
     208                  case BranchStmt::FallThrough:
     209                                assert( targetEntry->useFallExit() != "");
     210                                exitLabel = targetEntry->useFallExit();
     211                                break;
     212                  case BranchStmt::FallThroughDefault:
     213                                assert( targetEntry->useFallDefaultExit() != "");
     214                                exitLabel = targetEntry->useFallDefaultExit();
     215                                // check that fallthrough default comes before the default clause
     216                                if ( ! targetEntry->isFallDefaultValid() ) {
     217                                        SemanticError( branchStmt->location, "'fallthrough default' must precede the 'default' clause" );
     218                                }
    144219                                break;
    145220                  default:
     
    186261                Label contLabel = generator->newLabel("loopContinue", loopStmt);
    187262                enclosingControlStructures.push_back( Entry( loopStmt, brkLabel, contLabel ) );
     263                GuardAction( [this]() { enclosingControlStructures.pop_back(); } );
    188264        }
    189265
     
    196272
    197273                // this will take the necessary steps to add definitions of the previous two labels, if they are used.
    198                 loopStmt->set_body( mutateLoop( loopStmt->get_body(), e ) );
    199                 enclosingControlStructures.pop_back();
     274                loopStmt->body = mutateLoop( loopStmt->get_body(), e );
    200275                return loopStmt;
    201276        }
     
    223298                        Label brkLabel = generator->newLabel("blockBreak", ifStmt);
    224299                        enclosingControlStructures.push_back( Entry( ifStmt, brkLabel ) );
     300                        GuardAction( [this]() { enclosingControlStructures.pop_back(); } );
    225301                } // if
    226302        }
     
    232308                                set_breakLabel( enclosingControlStructures.back().useBreakExit() );
    233309                        } // if
    234                         enclosingControlStructures.pop_back();
    235310                } // if
    236311                return ifStmt;
     
    239314        void MLEMutator::premutate( CaseStmt *caseStmt ) {
    240315                visit_children = false;
     316
     317                // mark default as seen before visiting its statements to catch default loops
     318                if ( caseStmt->isDefault() ) {
     319                        enclosingControlStructures.back().seenDefault();
     320                } // if
     321
    241322                caseStmt->condition = maybeMutate( caseStmt->condition, *visitor );
    242                 fixBlock( caseStmt->stmts );
     323                Label fallLabel = generator->newLabel( "fallThrough", caseStmt );
     324                {
     325                        // ensure that stack isn't corrupted by exceptions in fixBlock
     326                        auto guard = makeFuncGuard( [&]() { enclosingControlStructures.push_back( Entry( caseStmt, fallLabel ) ); }, [this]() { enclosingControlStructures.pop_back(); } );
     327
     328                        // empty case statement
     329                        if( ! caseStmt->stmts.empty() ) {
     330                                // the parser ensures that all statements in a case are grouped into a block
     331                                CompoundStmt * block = strict_dynamic_cast< CompoundStmt * >( caseStmt->stmts.front() );
     332                                fixBlock( block->kids, true );
     333
     334                                // add fallthrough label if necessary
     335                                assert( ! enclosingControlStructures.empty() );
     336                                if ( enclosingControlStructures.back().isFallUsed() ) {
     337                                        std::list<Label> ls{ enclosingControlStructures.back().useFallExit() };
     338                                        caseStmt->stmts.push_back( new NullStmt( ls ) );
     339                                } // if
     340                        } // if
     341                }
     342                assert( ! enclosingControlStructures.empty() );
     343                assertf( dynamic_cast<SwitchStmt *>( enclosingControlStructures.back().get_controlStructure() ), "Control structure enclosing a case clause must be a switch, but is: %s", toCString( enclosingControlStructures.back().get_controlStructure() ) );
     344                if ( caseStmt->isDefault() ) {
     345                        if ( enclosingControlStructures.back().isFallDefaultUsed() ) {
     346                                // add fallthrough default label if necessary
     347                                std::list<Label> ls{ enclosingControlStructures.back().useFallDefaultExit() };
     348                                caseStmt->stmts.push_front( new NullStmt( ls ) );
     349                        } // if
     350                } // if
    243351        }
    244352
     
    246354                // generate a label for breaking out of a labeled switch
    247355                Label brkLabel = generator->newLabel("switchBreak", switchStmt);
    248                 enclosingControlStructures.push_back( Entry(switchStmt, brkLabel) );
     356                auto it = std::find_if( switchStmt->statements.rbegin(), switchStmt->statements.rend(), [](Statement * stmt) {
     357                        CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt );
     358                        return caseStmt->isDefault();
     359                });
     360                CaseStmt * defaultCase = it != switchStmt->statements.rend() ? strict_dynamic_cast<CaseStmt *>( *it ) : nullptr;
     361                Label fallDefaultLabel = defaultCase ? generator->newLabel( "fallThroughDefault", defaultCase ) : "";
     362                enclosingControlStructures.push_back( Entry(switchStmt, brkLabel, fallDefaultLabel) );
     363                GuardAction( [this]() { enclosingControlStructures.pop_back(); } );
     364
     365                // Collect valid labels for fallthrough. This is initially all labels at the same level as a case statement.
     366                // As labels are seen during traversal, they are removed, since fallthrough is not allowed to jump backwards.
     367                for ( Statement * stmt : switchStmt->statements ) {
     368                        CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt );
     369                        if ( caseStmt->stmts.empty() ) continue;
     370                        CompoundStmt * block = dynamic_cast< CompoundStmt * >( caseStmt->stmts.front() );
     371                        for ( Statement * stmt : block->kids ) {
     372                                for ( Label & l : stmt->labels ) {
     373                                        fallthroughLabels.insert( l );
     374                                }
     375                        }
     376                }
    249377        }
    250378
     
    271399
    272400                assert ( enclosingControlStructures.back() == switchStmt );
    273                 enclosingControlStructures.pop_back();
    274401                return switchStmt;
    275402        }
  • src/ControlStruct/MLEMutator.h

    r2efe4b8 r1cdfa82  
    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 : Thu Mar  8 16:42:32 2018
     13// Update Count     : 41
    1414//
    1515
     
    1919#include <map>                     // for map
    2020#include <string>                  // for string
     21#include <set>                     // for unordered_set
    2122
    2223#include "Common/PassVisitor.h"
     
    2930        class LabelGenerator;
    3031
    31         class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting {
     32        class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting, public WithGuards {
     33          public:
    3234                class Entry;
    33 
    34           public:
    3535                MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
    3636                ~MLEMutator();
     
    5252                Label &get_breakLabel() { return breakLabel; }
    5353                void set_breakLabel( Label newValue ) { breakLabel = newValue; }
    54           private:
     54
    5555                class Entry {
    5656                  public:
    57                         explicit Entry( Statement *_loop, Label _breakExit, Label _contExit = Label("") ) :
    58                                 loop( _loop ), breakExit( _breakExit ), contExit( _contExit ), breakUsed(false), contUsed(false) {}
     57                        // specialized constructors for each combination of statement with labelled break/continue/fallthrough that is valid to cleanup the use cases
     58                        explicit Entry( ForStmt *stmt, Label breakExit, Label contExit ) :
     59                                stmt( stmt ), breakExit( breakExit ), contExit( contExit ) {}
    5960
    60                         bool operator==( const Statement *stmt ) { return loop == stmt; }
    61                         bool operator!=( const Statement *stmt ) { return loop != stmt; }
     61                        explicit Entry( WhileStmt *stmt, Label breakExit, Label contExit ) :
     62                                stmt( stmt ), breakExit( breakExit ), contExit( contExit ) {}
    6263
    63                         bool operator==( const Entry &other ) { return loop == other.get_controlStructure(); }
     64                        explicit Entry( CompoundStmt *stmt, Label breakExit ) :
     65                                stmt( stmt ), breakExit( breakExit ) {}
    6466
    65                         Statement *get_controlStructure() const { return loop; }
     67                        explicit Entry( IfStmt *stmt, Label breakExit ) :
     68                                stmt( stmt ), breakExit( breakExit ) {}
     69
     70                        explicit Entry( CaseStmt *stmt, Label fallExit ) :
     71                                stmt( stmt ), fallExit( fallExit ) {}
     72
     73                        explicit Entry( SwitchStmt *stmt, Label breakExit, Label fallDefaultExit ) :
     74                                stmt( stmt ), breakExit( breakExit ), fallDefaultExit( fallDefaultExit ) {}
     75
     76                        bool operator==( const Statement *other ) { return stmt == other; }
     77                        bool operator!=( const Statement *other ) { return stmt != other; }
     78
     79                        bool operator==( const Entry &other ) { return stmt == other.get_controlStructure(); }
     80
     81                        Statement *get_controlStructure() const { return stmt; }
    6682
    6783                        Label useContExit() { contUsed = true; return contExit; }
    6884                        Label useBreakExit() { breakUsed = true; return breakExit; }
     85                        Label useFallExit() { fallUsed = true; return fallExit; }
     86                        Label useFallDefaultExit() { fallDefaultUsed = true; return fallDefaultExit; }
    6987
    7088                        bool isContUsed() const { return contUsed; }
    7189                        bool isBreakUsed() const { return breakUsed; }
     90                        bool isFallUsed() const { return fallUsed; }
     91                        bool isFallDefaultUsed() const { return fallDefaultUsed; }
     92                        void seenDefault() { fallDefaultValid = false; }
     93                        bool isFallDefaultValid() const { return fallDefaultValid; }
    7294                  private:
    73                         Statement *loop;
    74                         Label breakExit, contExit;
    75                         bool breakUsed, contUsed;
     95                        Statement *stmt;
     96                        Label breakExit, contExit, fallExit, fallDefaultExit;
     97                        bool breakUsed = false, contUsed = false, fallUsed = false, fallDefaultUsed = false;
     98                        bool fallDefaultValid = true;
    7699                };
    77100
     101          private:
    78102                std::map< Label, Statement * > *targetTable;
     103                std::set< Label > fallthroughLabels;
    79104                std::list< Entry > enclosingControlStructures;
    80105                Label breakLabel;
     
    87112                Statement * posthandleLoopStmt( LoopClass * loopStmt );
    88113
    89                 void fixBlock( std::list< Statement * > &kids );
     114                void fixBlock( std::list< Statement * > &kids, bool caseClause = false );
    90115        };
    91116} // namespace ControlStruct
  • src/GenPoly/Box.cc

    r2efe4b8 r1cdfa82  
    184184                        /// change the type of generic aggregate members to char[]
    185185                        void mutateMembers( AggregateDecl * aggrDecl );
     186                        /// returns the calculated sizeof expression for ty, or nullptr for use C sizeof()
     187                        Expression* genSizeof( Type* ty );
    186188
    187189                        /// Enters a new scope for type-variables, adding the type variables from ty
     
    383385                unsigned long n_members = 0;
    384386                bool firstMember = true;
    385                 for ( std::list< Declaration* >::const_iterator member = structDecl->get_members().begin(); member != structDecl->get_members().end(); ++member ) {
    386                         DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member );
     387                for ( Declaration* member : structDecl->get_members() ) {
     388                        DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( member );
    387389                        assert( dwt );
    388390                        Type *memberType = dwt->get_type();
     
    17371739                }
    17381740
     1741                Expression * PolyGenericCalculator::genSizeof( Type* ty ) {
     1742                        if ( ArrayType * aty = dynamic_cast<ArrayType *>(ty) ) {
     1743                                // generate calculated size for possibly generic array
     1744                                Expression * sizeofBase = genSizeof( aty->get_base() );
     1745                                if ( ! sizeofBase ) return nullptr;
     1746                                Expression * dim = aty->get_dimension();
     1747                                aty->set_dimension( nullptr );
     1748                                return makeOp( "?*?", sizeofBase, dim );
     1749                        } else if ( findGeneric( ty ) ) {
     1750                                // generate calculated size for generic type
     1751                                return new NameExpr( sizeofName( mangleType( ty ) ) );
     1752                        } else return nullptr;
     1753                }
     1754
    17391755                Expression *PolyGenericCalculator::postmutate( SizeofExpr *sizeofExpr ) {
    1740                         Type *ty = sizeofExpr->get_isType() ? sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result();
    1741                         if ( findGeneric( ty ) ) {
    1742                                 return new NameExpr( sizeofName( mangleType( ty ) ) );
    1743                         }
    1744                         return sizeofExpr;
     1756                        Type *ty = sizeofExpr->get_isType() ?
     1757                                sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result();
     1758                       
     1759                        Expression * gen = genSizeof( ty );
     1760                        return gen ? gen : sizeofExpr;
    17451761                }
    17461762
  • src/GenPoly/GenPoly.cc

    r2efe4b8 r1cdfa82  
    100100                if ( dynamic_cast< TypeInstType * >( type ) ) {
    101101                        return type;
     102                } else if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) {
     103                        return isPolyType( arrayType->base, env );
    102104                } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) {
    103105                        if ( hasPolyParams( structType->get_parameters(), env ) ) return type;
     
    115117                                return type;
    116118                        }
     119                } else if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) {
     120                        return isPolyType( arrayType->base, tyVars, env );
    117121                } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) {
    118122                        if ( hasPolyParams( structType->get_parameters(), tyVars, env ) ) return type;
  • src/GenPoly/InstantiateGeneric.cc

    r2efe4b8 r1cdfa82  
    484484        Expression * FixDtypeStatic::fixMemberExpr( AggrInst * inst, MemberExpr * memberExpr ) {
    485485                // need to cast dtype-static member expressions to their actual type before that type is erased.
     486                // NOTE: the casts here have the third argument (isGenerated) set to false so that these casts persist until Box, where they are needed.
    486487                auto & baseParams = *inst->get_baseParameters();
    487488                if ( isDtypeStatic( baseParams ) ) {
     
    503504                                        // Note: this currently creates more temporaries than is strictly necessary, since it does not check for duplicate uses of the same member expression.
    504505                                        static UniqueName tmpNamer( "_dtype_static_member_" );
    505                                         Expression * init = new CastExpr( new AddressExpr( memberExpr ), new PointerType( Type::Qualifiers(), concType->clone() ) );
     506                                        Expression * init = new CastExpr( new AddressExpr( memberExpr ), new PointerType( Type::Qualifiers(), concType->clone() ), false );
    506507                                        ObjectDecl * tmp = ObjectDecl::newObject( tmpNamer.newName(), new ReferenceType( Type::Qualifiers(), concType ), new SingleInit( init ) );
    507508                                        stmtsToAddBefore.push_back( new DeclStmt( tmp ) );
     
    509510                                } else {
    510511                                        // can simply add a cast to actual type
    511                                         return new CastExpr( memberExpr, concType );
     512                                        return new CastExpr( memberExpr, concType, false );
    512513                                }
    513514                        }
  • src/GenPoly/Lvalue.cc

    r2efe4b8 r1cdfa82  
    4545                Expression * mkDeref( Expression * arg ) {
    4646                        if ( SymTab::dereferenceOperator ) {
     47                                // note: reference depth can be arbitrarily deep here, so peel off the outermost pointer/reference, not just pointer because they are effecitvely equivalent in this pass
    4748                                VariableExpr * deref = new VariableExpr( SymTab::dereferenceOperator );
    4849                                deref->result = new PointerType( Type::Qualifiers(), deref->result );
     
    5859                }
    5960
    60                 struct ReferenceConversions final {
     61                struct ReferenceConversions final : public WithStmtsToAdd {
    6162                        Expression * postmutate( CastExpr * castExpr );
    6263                        Expression * postmutate( AddressExpr * addrExpr );
     
    9697                };
    9798
    98                 struct AddrRef final : public WithGuards {
     99                struct AddrRef final : public WithGuards, public WithVisitorRef<AddrRef>, public WithShortCircuiting {
    99100                        void premutate( AddressExpr * addrExpr );
    100101                        Expression * postmutate( AddressExpr * addrExpr );
    101102                        void premutate( Expression * expr );
     103                        void premutate( ApplicationExpr * appExpr );
     104                        void premutate( SingleInit * init );
     105
     106                        void handleNonAddr( Expression * );
    102107
    103108                        bool first = true;
    104109                        bool current = false;
    105110                        int refDepth = 0;
     111                        bool addCast = false;
    106112                };
    107113        } // namespace
     
    113119        }
    114120
    115         void convertLvalue( std::list< Declaration* >& translationUnit ) {
     121        void convertLvalue( std::list< Declaration* > & translationUnit ) {
    116122                PassVisitor<ReferenceConversions> refCvt;
    117123                PassVisitor<ReferenceTypeElimination> elim;
     
    149155                                        // use type of return variable rather than expr result type, since it may have been changed to a pointer type
    150156                                        FunctionType * ftype = GenPoly::getFunctionType( func->get_type() );
    151                                         Type * ret = ftype->get_returnVals().empty() ? nullptr : ftype->get_returnVals().front()->get_type();
    152                                         return func->get_linkage() == LinkageSpec::Intrinsic && dynamic_cast<ReferenceType *>( ret );
     157                                        Type * ret = ftype->returnVals.empty() ? nullptr : ftype->returnVals.front()->get_type();
     158                                        return func->linkage == LinkageSpec::Intrinsic && dynamic_cast<ReferenceType *>( ret );
    153159                                }
    154160                        }
     
    159165                        if ( isIntrinsicReference( appExpr ) ) {
    160166                                // eliminate reference types from intrinsic applications - now they return lvalues
    161                                 Type * result = appExpr->get_result();
    162                                 appExpr->set_result( result->stripReferences()->clone() );
    163                                 appExpr->get_result()->set_lvalue( true );
     167                                Type * result = appExpr->result;
     168                                appExpr->result = result->stripReferences()->clone();
     169                                appExpr->result->set_lvalue( true );
    164170                                if ( ! inIntrinsic ) {
    165171                                        // when not in an intrinsic function, add a cast to
    166172                                        // don't add cast when in an intrinsic function, since they already have the cast
    167173                                        Expression * ret = new CastExpr( appExpr, result );
    168                                         ret->set_env( appExpr->get_env() );
    169                                         appExpr->set_env( nullptr );
     174                                        std::swap( ret->env, appExpr->env );
    170175                                        return ret;
    171176                                }
     
    185190                                assertf( ftype, "Function declaration does not have function type." );
    186191                                // can be of differing lengths only when function is variadic
    187                                 assertf( ftype->get_parameters().size() == appExpr->get_args().size() || ftype->get_isVarArgs(), "ApplicationExpr args do not match formal parameter type." );
     192                                assertf( ftype->parameters.size() == appExpr->args.size() || ftype->isVarArgs, "ApplicationExpr args do not match formal parameter type." );
    188193
    189194
    190195                                unsigned int i = 0;
    191                                 const unsigned int end = ftype->get_parameters().size();
    192                                 for ( auto p : unsafe_group_iterate( appExpr->get_args(), ftype->get_parameters() ) ) {
     196                                const unsigned int end = ftype->parameters.size();
     197                                for ( auto p : unsafe_group_iterate( appExpr->args, ftype->parameters ) ) {
    193198                                        if (i == end) break;
    194199                                        Expression *& arg = std::get<0>( p );
     
    196201                                        PRINT(
    197202                                                std::cerr << "pair<0>: " << arg << std::endl;
     203                                                std::cerr << " -- " << arg->result << std::endl;
    198204                                                std::cerr << "pair<1>: " << formal << std::endl;
    199205                                        )
    200206                                        if ( dynamic_cast<ReferenceType*>( formal ) ) {
    201                                                 if ( isIntrinsicReference( arg ) ) { // do not combine conditions, because that changes the meaning of the else if
    202                                                         if ( function->get_linkage() != LinkageSpec::Intrinsic ) { // intrinsic functions that turn pointers into references
    203                                                                 // if argument is dereference or array subscript, the result isn't REALLY a reference, so it's not necessary to fix the argument
    204                                                                 PRINT(
    205                                                                         std::cerr << "===is intrinsic arg in non-intrinsic call - adding address" << std::endl;
    206                                                                 )
    207                                                                 arg = new AddressExpr( arg );
    208                                                         }
    209                                                 } else if ( function->get_linkage() == LinkageSpec::Intrinsic ) {
    210                                                         // std::cerr << "===adding deref to arg" << std::endl;
    211                                                         // if the parameter is a reference, add a dereference to the reference-typed argument.
    212                                                         Type * baseType = InitTweak::getPointerBase( arg->get_result() );
    213                                                         assertf( baseType, "parameter is reference, arg must be pointer or reference: %s", toString( arg->get_result() ).c_str() );
    214                                                         arg->set_result( new PointerType{ Type::Qualifiers(), baseType->clone() } );
     207                                                PRINT(
     208                                                        std::cerr << "===formal is reference" << std::endl;
     209                                                )
     210                                                // TODO: it's likely that the second condition should be ... && ! isIntrinsicReference( arg ), but this requires investigation.
     211
     212                                                if ( function->get_linkage() != LinkageSpec::Intrinsic && isIntrinsicReference( arg ) ) {
     213                                                        // needed for definition of prelude functions, etc.
     214                                                        // if argument is dereference or array subscript, the result isn't REALLY a reference, but non-intrinsic functions expect a reference: take address
     215
     216                                                        // NOTE: previously, this condition fixed
     217                                                        //   void f(int *&);
     218                                                        //   int & x = ...;
     219                                                        //   f(&x);
     220                                                        // But now this is taken care of by a reference cast added by AddrRef. Need to find a new
     221                                                        // example or remove this branch.
     222
     223                                                        PRINT(
     224                                                                std::cerr << "===is intrinsic arg in non-intrinsic call - adding address" << std::endl;
     225                                                        )
     226                                                        arg = new AddressExpr( arg );
     227                                                // } else if ( function->get_linkage() == LinkageSpec::Intrinsic && InitTweak::getPointerBase( arg->result ) ) {
     228                                                } else if ( function->get_linkage() == LinkageSpec::Intrinsic && arg->result->referenceDepth() != 0 ) {
     229                                                        // argument is a 'real' reference, but function expects a C lvalue: add a dereference to the reference-typed argument
     230                                                        PRINT(
     231                                                                std::cerr << "===is non-intrinsic arg in intrinsic call - adding deref to arg" << std::endl;
     232                                                        )
     233                                                        Type * baseType = InitTweak::getPointerBase( arg->result );
     234                                                        assertf( baseType, "parameter is reference, arg must be pointer or reference: %s", toString( arg->result ).c_str() );
     235                                                        arg->set_result( new PointerType( Type::Qualifiers(), baseType->clone() ) );
    215236                                                        arg = mkDeref( arg );
     237                                                        // assertf( arg->result->referenceDepth() == 0, "Reference types should have been eliminated from intrinsic function calls, but weren't: %s", toCString( arg->result ) );
    216238                                                }
    217239                                        }
     
    223245
    224246                // idea: &&&E: get outer &, inner &
    225                 // at inner &, record depth D of reference type
     247                // at inner &, record depth D of reference type of argument of &
    226248                // at outer &, add D derefs.
    227                 void AddrRef::premutate( Expression * ) {
     249                void AddrRef::handleNonAddr( Expression * ) {
     250                        // non-address-of: reset status variables:
     251                        // * current expr is NOT the first address-of expr in an address-of chain
     252                        // * next seen address-of expr IS the first in the chain.
    228253                        GuardValue( current );
    229254                        GuardValue( first );
     
    232257                }
    233258
     259                void AddrRef::premutate( Expression * expr ) {
     260                        handleNonAddr( expr );
     261                        GuardValue( addCast );
     262                        addCast = false;
     263                }
     264
    234265                void AddrRef::premutate( AddressExpr * ) {
    235266                        GuardValue( current );
    236267                        GuardValue( first );
    237                         current = first;
    238                         first = false;
    239                         if ( current ) {
     268                        current = first; // is this the first address-of in the chain?
     269                        first = false;   // from here out, no longer possible for next address-of to be first in chain
     270                        if ( current ) { // this is the outermost address-of in a chain
    240271                                GuardValue( refDepth );
    241                                 refDepth = 0;
     272                                refDepth = 0;  // set depth to 0 so that postmutate can find the innermost address-of easily
    242273                        }
    243274                }
    244275
    245276                Expression * AddrRef::postmutate( AddressExpr * addrExpr ) {
     277                        PRINT( std::cerr << "addr ref at " << addrExpr << std::endl; )
    246278                        if ( refDepth == 0 ) {
    247                                 if ( ! isIntrinsicReference( addrExpr->get_arg() ) ) {
     279                                PRINT( std::cerr << "depth 0, get new depth..." << std::endl; )
     280                                // this is the innermost address-of in a chain, record depth D
     281                                if ( ! isIntrinsicReference( addrExpr->arg ) ) {
    248282                                        // try to avoid ?[?]
    249                                         refDepth = addrExpr->get_arg()->get_result()->referenceDepth();
    250                                 }
    251                         }
    252                         if ( current ) {
     283                                        // xxx - is this condition still necessary? intrinsicReferences should have a cast around them at this point, so I don't think this condition ever fires.
     284                                        refDepth = addrExpr->arg->result->referenceDepth();
     285                                        PRINT( std::cerr << "arg not intrinsic reference, new depth is: " << refDepth << std::endl; )
     286                                } else {
     287                                        assertf( false, "AddrRef : address-of should not have intrinsic reference argument: %s", toCString( addrExpr->arg ) );
     288                                }
     289                        }
     290                        if ( current ) { // this is the outermost address-of in a chain
     291                                PRINT( std::cerr << "current, depth is: " << refDepth << std::endl; )
    253292                                Expression * ret = addrExpr;
    254293                                while ( refDepth ) {
     294                                        // add one dereference for each
    255295                                        ret = mkDeref( ret );
    256296                                        refDepth--;
    257297                                }
     298
     299                                // if addrExpr depth is 0, then the result is a pointer because the arg was depth 1 and not lvalue.
     300                                // This means the dereference result is not a reference, is lvalue, and one less pointer depth than
     301                                // the addrExpr. Thus the cast is meaningless.
     302                                // TODO: One thing to double check is whether it is possible for the types to differ outside of the single
     303                                // pointer level (i.e. can the base type of addrExpr differ from the type of addrExpr-arg?).
     304                                // If so then the cast might need to be added, conditional on a more sophisticated check.
     305                                if ( addCast && addrExpr->result->referenceDepth() != 0 ) {
     306                                        PRINT( std::cerr << "adding cast to " << addrExpr->result << std::endl; )
     307                                        return new CastExpr( ret, addrExpr->result->clone() );
     308                                }
    258309                                return ret;
    259310                        }
     311                        PRINT( std::cerr << "not current..." << std::endl; )
    260312                        return addrExpr;
    261313                }
     314
     315                void AddrRef::premutate( ApplicationExpr * appExpr ) {
     316                        visit_children = false;
     317                        GuardValue( addCast );
     318                        handleNonAddr( appExpr );
     319                        for ( Expression *& arg : appExpr->args ) {
     320                                // each argument with address-of requires a cast
     321                                addCast = true;
     322                                arg = arg->acceptMutator( *visitor );
     323                        }
     324                }
     325
     326                void AddrRef::premutate( SingleInit * ) {
     327                        GuardValue( addCast );
     328                        // each initialization context with address-of requires a cast
     329                        addCast = true;
     330                }
     331
    262332
    263333                Expression * ReferenceConversions::postmutate( AddressExpr * addrExpr ) {
     
    276346                        // pointer casts in the right places.
    277347
    278                         // conversion to reference type
    279                         if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( castExpr->get_result() ) ) {
    280                                 (void)refType;
    281                                 if ( ReferenceType * otherRef = dynamic_cast< ReferenceType * >( castExpr->get_arg()->get_result() ) ) {
    282                                         // nothing to do if casting from reference to reference.
    283                                         (void)otherRef;
    284                                         PRINT( std::cerr << "convert reference to reference -- nop" << std::endl; )
    285                                         if ( isIntrinsicReference( castExpr->get_arg() ) ) {
    286                                                 Expression * callExpr = castExpr->get_arg();
    287                                                 PRINT(
    288                                                         std::cerr << "but arg is deref -- &" << std::endl;
    289                                                         std::cerr << callExpr << std::endl;
    290                                                 )
    291                                                 callExpr = new AddressExpr( callExpr ); // this doesn't work properly for multiple casts
    292                                                 callExpr->set_result( refType->clone() );
    293                                                 // move environment out to new top-level
    294                                                 callExpr->set_env( castExpr->get_env() );
    295                                                 castExpr->set_arg( nullptr );
    296                                                 castExpr->set_env( nullptr );
    297                                                 return callExpr;
    298                                         }
    299                                         int depth1 = refType->referenceDepth();
    300                                         int depth2 = otherRef->referenceDepth();
    301                                         int diff = depth1-depth2;
    302                                         if ( diff == 0 ) {
    303                                                 // conversion between references of the same depth
    304                                                 assertf( depth1 == depth2, "non-intrinsic reference with cast of reference to reference not yet supported: %d %d %s", depth1, depth2, toString( castExpr ).c_str() );
    305                                                 PRINT( std::cerr << castExpr << std::endl; )
    306                                                 return castExpr;
    307                                         } else if ( diff < 0 ) {
    308                                                 // conversion from reference to reference with less depth (e.g. int && -> int &): add dereferences
    309                                                 Expression * ret = castExpr->arg;
    310                                                 for ( int i = 0; i < diff; ++i ) {
    311                                                         ret = mkDeref( ret );
    312                                                 }
    313                                                 ret->env = castExpr->env;
    314                                                 ret->result = castExpr->result;
    315                                                 ret->result->set_lvalue( true ); // ensure result is lvalue
    316                                                 castExpr->env = nullptr;
    317                                                 castExpr->arg = nullptr;
    318                                                 castExpr->result = nullptr;
    319                                                 return ret;
    320                                         } else if ( diff > 0 ) {
    321                                                 // conversion from reference to reference with more depth (e.g. int & -> int &&): add address-of
    322                                                 Expression * ret = castExpr->arg;
    323                                                 for ( int i = 0; i < diff; ++i ) {
    324                                                         ret = new AddressExpr( ret );
    325                                                 }
    326                                                 ret->env = castExpr->env;
    327                                                 ret->result = castExpr->result;
    328                                                 castExpr->env = nullptr;
    329                                                 castExpr->arg = nullptr;
    330                                                 castExpr->result = nullptr;
    331                                                 return ret;
    332                                         }
    333 
    334                                         assertf( depth1 == depth2, "non-intrinsic reference with cast of reference to reference not yet supported: %d %d %s", depth1, depth2, toString( castExpr ).c_str() );
    335                                         PRINT( std::cerr << castExpr << std::endl; )
     348                        // Note: reference depth difference is the determining factor in what code is run, rather than whether something is
     349                        // reference type or not, since conversion still needs to occur when both types are references that differ in depth.
     350
     351                        Type * destType = castExpr->result;
     352                        Type * srcType = castExpr->arg->result;
     353                        int depth1 = destType->referenceDepth();
     354                        int depth2 = srcType->referenceDepth();
     355                        int diff = depth1 - depth2;
     356
     357                        if ( diff > 0 && ! srcType->get_lvalue() ) {
     358                                // rvalue to reference conversion -- introduce temporary
     359                                // know that reference depth of cast argument is 0, need to introduce n temporaries for reference depth of n, e.g.
     360                                //   (int &&&)3;
     361                                // becomes
     362                                //   int __ref_tmp_0 = 3;
     363                                //   int & __ref_tmp_1 = _&_ref_tmp_0;
     364                                //   int && __ref_tmp_2 = &__ref_tmp_1;
     365                                //   &__ref_tmp_2;
     366                                // the last & comes from the remaining reference conversion code
     367                                SemanticWarning( castExpr->arg->location, Warning::RvalueToReferenceConversion, toCString( castExpr->arg ) );
     368
     369                                static UniqueName tempNamer( "__ref_tmp_" );
     370                                ObjectDecl * temp = ObjectDecl::newObject( tempNamer.newName(), castExpr->arg->result->clone(), new SingleInit( castExpr->arg ) );
     371                                PRINT( std::cerr << "made temp: " << temp << std::endl; )
     372                                stmtsToAddBefore.push_back( new DeclStmt( temp ) );
     373                                for ( int i = 0; i < depth1-1; i++ ) { // xxx - maybe this should be diff-1? check how this works with reference type for srcType
     374                                        ObjectDecl * newTemp = ObjectDecl::newObject( tempNamer.newName(), new ReferenceType( Type::Qualifiers(), temp->type->clone() ), new SingleInit( new AddressExpr( new VariableExpr( temp ) ) ) );
     375                                        PRINT( std::cerr << "made temp" << i << ": " << newTemp << std::endl; )
     376                                        stmtsToAddBefore.push_back( new DeclStmt( newTemp ) );
     377                                        temp = newTemp;
     378                                }
     379                                // update diff so that remaining code works out correctly
     380                                castExpr->arg = new VariableExpr( temp );
     381                                PRINT( std::cerr << "update cast to: " << castExpr << std::endl; )
     382                                srcType = castExpr->arg->result;
     383                                depth2 = srcType->referenceDepth();
     384                                diff = depth1 - depth2;
     385                                assert( diff == 1 );
     386                        }
     387
     388                        // handle conversion between different depths
     389                        PRINT (
     390                                if ( depth1 || depth2 ) {
     391                                        std::cerr << "destType: " << destType << " / srcType: " << srcType << std::endl;
     392                                        std::cerr << "depth: " << depth1 << " / " << depth2 << std::endl;
     393                                }
     394                        )
     395                        if ( diff > 0 ) {
     396                                // conversion to type with more depth (e.g. int & -> int &&): add address-of for each level of difference
     397                                Expression * ret = castExpr->arg;
     398                                for ( int i = 0; i < diff; ++i ) {
     399                                        ret = new AddressExpr( ret );
     400                                }
     401                                if ( srcType->get_lvalue() && srcType->get_qualifiers() != strict_dynamic_cast<ReferenceType *>( destType )->base->get_qualifiers() ) {
     402                                        // must keep cast if cast-to type is different from the actual type
     403                                        castExpr->arg = ret;
    336404                                        return castExpr;
    337                                 } else if ( castExpr->arg->result->get_lvalue() ) {
    338                                         // conversion from lvalue to reference
    339                                         // xxx - keep cast, but turn into pointer cast??
    340                                         // xxx - memory
    341                                         PRINT(
    342                                                 std::cerr << "convert lvalue to reference -- &" << std::endl;
    343                                                 std::cerr << castExpr->arg << std::endl;
    344                                         )
    345                                         AddressExpr * ret = new AddressExpr( castExpr->arg );
    346                                         if ( refType->base->get_qualifiers() != castExpr->arg->result->get_qualifiers() ) {
    347                                                 // must keep cast if cast-to type is different from the actual type
    348                                                 castExpr->arg = ret;
    349                                                 return castExpr;
    350                                         }
    351                                         ret->env = castExpr->env;
    352                                         ret->result = castExpr->result;
    353                                         castExpr->env = nullptr;
    354                                         castExpr->arg = nullptr;
    355                                         castExpr->result = nullptr;
    356                                         return ret;
    357                                 } else {
    358                                         // rvalue to reference conversion -- introduce temporary
    359                                 }
    360                                 assertf( false, "Only conversions to reference from lvalue are currently supported: %s", toString( castExpr ).c_str() );
    361                         } else if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( castExpr->arg->result ) ) {
    362                                 (void)refType;
    363                                 // conversion from reference to rvalue
    364                                 PRINT(
    365                                         std::cerr << "convert reference to rvalue -- *" << std::endl;
    366                                         std::cerr << "was = " << castExpr << std::endl;
    367                                 )
     405                                }
     406                                ret->env = castExpr->env;
     407                                ret->result = castExpr->result;
     408                                castExpr->env = nullptr;
     409                                castExpr->arg = nullptr;
     410                                castExpr->result = nullptr;
     411                                return ret;
     412                        } else if ( diff < 0 ) {
     413                                // conversion to type with less depth (e.g. int && -> int &): add dereferences for each level of difference
     414                                diff = -diff; // care only about magnitude now
    368415                                Expression * ret = castExpr->arg;
    369                                 TypeSubstitution * env = castExpr->env;
    370                                 castExpr->set_env( nullptr );
    371                                 if ( ! isIntrinsicReference( ret ) ) {
    372                                         // dereference if not already dereferenced
     416                                for ( int i = 0; i < diff; ++i ) {
    373417                                        ret = mkDeref( ret );
    374                                 }
    375                                 if ( ResolvExpr::typesCompatibleIgnoreQualifiers( castExpr->result, castExpr->arg->result->stripReferences(), SymTab::Indexer() ) ) {
    376                                         // can remove cast if types are compatible, changing expression type to value type
    377                                         ret->result = castExpr->result->clone();
    378                                         ret->result->set_lvalue( true );  // ensure result is lvalue
    379                                         castExpr->arg = nullptr;
    380                                 } else {
     418                                        // xxx - try removing one reference here? actually, looks like mkDeref already does this, so more closely look at the types generated.
     419                                }
     420                                if ( ! ResolvExpr::typesCompatibleIgnoreQualifiers( destType->stripReferences(), srcType->stripReferences(), SymTab::Indexer() ) ) {
    381421                                        // must keep cast if types are different
    382422                                        castExpr->arg = ret;
    383                                         ret = castExpr;
    384                                 }
    385                                 ret->set_env( env );
    386                                 PRINT( std::cerr << "now: " << ret << std::endl; )
     423                                        return castExpr;
     424                                }
     425                                ret->env = castExpr->env;
     426                                ret->result = castExpr->result;
     427                                ret->result->set_lvalue( true ); // ensure result is lvalue
     428                                castExpr->env = nullptr;
     429                                castExpr->arg = nullptr;
     430                                castExpr->result = nullptr;
    387431                                return ret;
    388                         }
    389                         return castExpr;
     432                        } else {
     433                                assert( diff == 0 );
     434                                // conversion between references of the same depth
     435                                if ( ResolvExpr::typesCompatible( castExpr->result, castExpr->arg->result, SymTab::Indexer() ) && castExpr->isGenerated ) {
     436                                        // Remove useless generated casts
     437                                        PRINT(
     438                                                std::cerr << "types are compatible, removing cast: " << castExpr << std::endl;
     439                                                std::cerr << "-- " << castExpr->result << std::endl;
     440                                                std::cerr << "-- " << castExpr->arg->result << std::endl;
     441                                        )
     442                                        Expression * ret = castExpr->arg;
     443                                        castExpr->arg = nullptr;
     444                                        std::swap( castExpr->env, ret->env );
     445                                        return ret;
     446                                }
     447                                return castExpr;
     448                        }
    390449                }
    391450
    392451                Type * ReferenceTypeElimination::postmutate( ReferenceType * refType ) {
    393                         Type * base = refType->get_base();
     452                        Type * base = refType->base;
    394453                        Type::Qualifiers qualifiers = refType->get_qualifiers();
    395                         refType->set_base( nullptr );
     454                        refType->base = nullptr;
    396455                        return new PointerType( qualifiers, base );
    397456                }
     
    400459                Expression * GeneralizedLvalue::applyTransformation( Expression * expr, Expression * arg, Func mkExpr ) {
    401460                        if ( CommaExpr * commaExpr = dynamic_cast< CommaExpr * >( arg ) ) {
    402                                 Expression * arg1 = commaExpr->get_arg1()->clone();
    403                                 Expression * arg2 = commaExpr->get_arg2()->clone();
     461                                Expression * arg1 = commaExpr->arg1->clone();
     462                                Expression * arg2 = commaExpr->arg2->clone();
    404463                                Expression * ret = new CommaExpr( arg1, mkExpr( arg2 )->acceptMutator( *visitor ) );
    405                                 ret->set_env( expr->get_env() );
    406                                 expr->set_env( nullptr );
     464                                ret->env = expr->env;
     465                                expr->env = nullptr;
    407466                                return ret;
    408467                        } else if ( ConditionalExpr * condExpr = dynamic_cast< ConditionalExpr * >( arg ) ) {
    409                                 Expression * arg1 = condExpr->get_arg1()->clone();
    410                                 Expression * arg2 = condExpr->get_arg2()->clone();
    411                                 Expression * arg3 = condExpr->get_arg3()->clone();
     468                                Expression * arg1 = condExpr->arg1->clone();
     469                                Expression * arg2 = condExpr->arg2->clone();
     470                                Expression * arg3 = condExpr->arg3->clone();
    412471                                ConditionalExpr * ret = new ConditionalExpr( arg1, mkExpr( arg2 )->acceptMutator( *visitor ), mkExpr( arg3 )->acceptMutator( *visitor ) );
    413                                 ret->set_env( expr->get_env() );
    414                                 expr->set_env( nullptr );
     472                                ret->env = expr->env;
     473                                expr->env = nullptr;
    415474
    416475                                // conditional expr type may not be either of the argument types, need to unify
     
    420479                                AssertionSet needAssertions, haveAssertions;
    421480                                OpenVarSet openVars;
    422                                 unify( ret->get_arg2()->get_result(), ret->get_arg3()->get_result(), newEnv, needAssertions, haveAssertions, openVars, SymTab::Indexer(), commonType );
    423                                 ret->set_result( commonType ? commonType : ret->get_arg2()->get_result()->clone() );
     481                                unify( ret->arg2->result, ret->arg3->result, newEnv, needAssertions, haveAssertions, openVars, SymTab::Indexer(), commonType );
     482                                ret->result = commonType ? commonType : ret->arg2->result->clone();
    424483                                return ret;
    425484                        }
     
    428487
    429488                Expression * GeneralizedLvalue::postmutate( MemberExpr * memExpr ) {
    430                         return applyTransformation( memExpr, memExpr->get_aggregate(), [=]( Expression * aggr ) { return new MemberExpr( memExpr->get_member(), aggr ); } );
     489                        return applyTransformation( memExpr, memExpr->aggregate, [=]( Expression * aggr ) { return new MemberExpr( memExpr->member, aggr ); } );
    431490                }
    432491
    433492                Expression * GeneralizedLvalue::postmutate( AddressExpr * addrExpr ) {
    434                         return applyTransformation( addrExpr, addrExpr->get_arg(), []( Expression * arg ) { return new AddressExpr( arg ); } );
     493                        return applyTransformation( addrExpr, addrExpr->arg, []( Expression * arg ) { return new AddressExpr( arg ); } );
    435494                }
    436495
    437496                Expression * CollapseAddrDeref::postmutate( AddressExpr * addrExpr ) {
    438                         Expression * arg = addrExpr->get_arg();
     497                        Expression * arg = addrExpr->arg;
    439498                        if ( isIntrinsicReference( arg ) ) {
    440499                                std::string fname = InitTweak::getFunctionName( arg );
     
    442501                                        Expression *& arg0 = InitTweak::getCallArg( arg, 0 );
    443502                                        Expression * ret = arg0;
    444                                         ret->set_env( addrExpr->get_env() );
     503                                        ret->set_env( addrExpr->env );
    445504                                        arg0 = nullptr;
    446                                         addrExpr->set_env( nullptr );
     505                                        addrExpr->env = nullptr;
    447506                                        return ret;
    448507                                }
     
    470529                                        // }
    471530                                        if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( arg ) ) {
    472                                                 Expression * ret = addrExpr->get_arg();
    473                                                 ret->set_env( appExpr->get_env() );
    474                                                 addrExpr->set_arg( nullptr );
    475                                                 appExpr->set_env( nullptr );
     531                                                Expression * ret = addrExpr->arg;
     532                                                ret->env = appExpr->env;
     533                                                addrExpr->arg = nullptr;
     534                                                appExpr->env = nullptr;
    476535                                                return ret;
    477536                                        }
  • src/InitTweak/InitTweak.cc

    r2efe4b8 r1cdfa82  
    529529                }
    530530                if ( dynamic_cast< ReferenceType * >( dst->result ) ) {
    531                         dst = new AddressExpr( dst );
     531                        for (int depth = dst->result->referenceDepth(); depth > 0; depth--) {
     532                                dst = new AddressExpr( dst );
     533                        }
    532534                } else {
    533535                        dst = new CastExpr( dst, new ReferenceType( noQualifiers, dst->result->clone() ) );
    534536                }
    535537                if ( dynamic_cast< ReferenceType * >( src->result ) ) {
    536                         src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) );
     538                        for (int depth = src->result->referenceDepth(); depth > 0; depth--) {
     539                                src = new AddressExpr( src );
     540                        }
     541                        // src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) );
    537542                }
    538543                return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } );
  • src/Makefile.in

    r2efe4b8 r1cdfa82  
    251251        SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \
    252252        SynTree/driver_cfa_cpp-BaseSyntaxNode.$(OBJEXT) \
    253         SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT) \
     253        SynTree/driver_cfa_cpp-DeclReplacer.$(OBJEXT) \
    254254        Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \
    255255        Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) \
     
    529529        SynTree/Initializer.cc SynTree/TypeSubstitution.cc \
    530530        SynTree/Attribute.cc SynTree/BaseSyntaxNode.cc \
    531         SynTree/VarExprReplacer.cc Tuples/TupleAssignment.cc \
     531        SynTree/DeclReplacer.cc Tuples/TupleAssignment.cc \
    532532        Tuples/TupleExpansion.cc Tuples/Explode.cc \
    533533        Virtual/ExpandCasts.cc
     
    919919SynTree/driver_cfa_cpp-BaseSyntaxNode.$(OBJEXT):  \
    920920        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
    921 SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT):  \
     921SynTree/driver_cfa_cpp-DeclReplacer.$(OBJEXT):  \
    922922        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
    923923Tuples/$(am__dirstamp):
     
    10481048@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-CompoundStmt.Po@am__quote@
    10491049@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Constant.Po@am__quote@
     1050@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Po@am__quote@
    10501051@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-DeclStmt.Po@am__quote@
    10511052@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Declaration.Po@am__quote@
     
    10691070@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-TypeofType.Po@am__quote@
    10701071@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po@am__quote@
    1071 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po@am__quote@
    10721072@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@
    10731073@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@
     
    25352535@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-BaseSyntaxNode.obj `if test -f 'SynTree/BaseSyntaxNode.cc'; then $(CYGPATH_W) 'SynTree/BaseSyntaxNode.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/BaseSyntaxNode.cc'; fi`
    25362536
    2537 SynTree/driver_cfa_cpp-VarExprReplacer.o: SynTree/VarExprReplacer.cc
    2538 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-VarExprReplacer.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo -c -o SynTree/driver_cfa_cpp-VarExprReplacer.o `test -f 'SynTree/VarExprReplacer.cc' || echo '$(srcdir)/'`SynTree/VarExprReplacer.cc
    2539 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po
    2540 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/VarExprReplacer.cc' object='SynTree/driver_cfa_cpp-VarExprReplacer.o' libtool=no @AMDEPBACKSLASH@
    2541 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2542 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarExprReplacer.o `test -f 'SynTree/VarExprReplacer.cc' || echo '$(srcdir)/'`SynTree/VarExprReplacer.cc
    2543 
    2544 SynTree/driver_cfa_cpp-VarExprReplacer.obj: SynTree/VarExprReplacer.cc
    2545 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-VarExprReplacer.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo -c -o SynTree/driver_cfa_cpp-VarExprReplacer.obj `if test -f 'SynTree/VarExprReplacer.cc'; then $(CYGPATH_W) 'SynTree/VarExprReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarExprReplacer.cc'; fi`
    2546 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po
    2547 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/VarExprReplacer.cc' object='SynTree/driver_cfa_cpp-VarExprReplacer.obj' libtool=no @AMDEPBACKSLASH@
    2548 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2549 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarExprReplacer.obj `if test -f 'SynTree/VarExprReplacer.cc'; then $(CYGPATH_W) 'SynTree/VarExprReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarExprReplacer.cc'; fi`
     2537SynTree/driver_cfa_cpp-DeclReplacer.o: SynTree/DeclReplacer.cc
     2538@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-DeclReplacer.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Tpo -c -o SynTree/driver_cfa_cpp-DeclReplacer.o `test -f 'SynTree/DeclReplacer.cc' || echo '$(srcdir)/'`SynTree/DeclReplacer.cc
     2539@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Po
     2540@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/DeclReplacer.cc' object='SynTree/driver_cfa_cpp-DeclReplacer.o' libtool=no @AMDEPBACKSLASH@
     2541@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2542@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-DeclReplacer.o `test -f 'SynTree/DeclReplacer.cc' || echo '$(srcdir)/'`SynTree/DeclReplacer.cc
     2543
     2544SynTree/driver_cfa_cpp-DeclReplacer.obj: SynTree/DeclReplacer.cc
     2545@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-DeclReplacer.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Tpo -c -o SynTree/driver_cfa_cpp-DeclReplacer.obj `if test -f 'SynTree/DeclReplacer.cc'; then $(CYGPATH_W) 'SynTree/DeclReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/DeclReplacer.cc'; fi`
     2546@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-DeclReplacer.Po
     2547@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/DeclReplacer.cc' object='SynTree/driver_cfa_cpp-DeclReplacer.obj' libtool=no @AMDEPBACKSLASH@
     2548@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2549@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-DeclReplacer.obj `if test -f 'SynTree/DeclReplacer.cc'; then $(CYGPATH_W) 'SynTree/DeclReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/DeclReplacer.cc'; fi`
    25502550
    25512551Tuples/driver_cfa_cpp-TupleAssignment.o: Tuples/TupleAssignment.cc
  • src/Parser/DeclarationNode.cc

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 15:37:17 2018
    13 // Update Count     : 1033
     12// Last Modified On : Fri Apr 20 22:37:20 2018
     13// Update Count     : 1063
    1414//
    1515
     
    4747const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" };
    4848const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" };
    49 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "NoBuiltinTypeNames" };
     49const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "zero_t", "one_t", "NoBuiltinTypeNames" };
    5050
    5151UniqueName DeclarationNode::anonymous( "__anonymous" );
     
    7171        attr.expr = nullptr;
    7272        attr.type = nullptr;
     73
     74        assert.condition = nullptr;
     75        assert.message = nullptr;
    7376}
    7477
     
    8891        // asmName, no delete, passed to next stage
    8992        delete initializer;
     93
     94        delete assert.condition;
     95        delete assert.message;
    9096}
    9197
     
    117123        newnode->attr.expr = maybeClone( attr.expr );
    118124        newnode->attr.type = maybeClone( attr.type );
     125
     126        newnode->assert.condition = maybeClone( assert.condition );
     127        newnode->assert.message = maybeClone( assert.message );
    119128        return newnode;
    120129} // DeclarationNode::clone
     
    434443        return newnode;
    435444}
     445
     446DeclarationNode * DeclarationNode::newStaticAssert( ExpressionNode * condition, Expression * message ) {
     447        DeclarationNode * newnode = new DeclarationNode;
     448        newnode->assert.condition = condition;
     449        newnode->assert.message = message;
     450        return newnode;
     451}
     452
    436453
    437454void appendError( string & dst, const string & src ) {
     
    544561
    545562        checkQualifiers( type, q->type );
     563        if ( (builtin == Zero || builtin == One) && error.length() == 0 ) {
     564                SemanticWarning( yylloc, Warning::BadQualifiersZeroOne, Type::QualifiersNames[ilog2( q->type->qualifiers.val )], builtinTypeNames[builtin] );
     565//              appendError( error, string( "questionable qualifiers" ) );
     566        } // if
    546567        addQualifiersToType( q->type, type );
    547568
     
    907928                                delete newType->aggInst.aggregate->enumeration.constants;
    908929                                newType->aggInst.aggregate->enumeration.constants = nullptr;
     930                                newType->aggInst.aggregate->enumeration.body = false;
    909931                        } else {
    910932                                assert( newType->aggInst.aggregate->kind == TypeData::Aggregate );
    911933                                delete newType->aggInst.aggregate->aggregate.fields;
    912934                                newType->aggInst.aggregate->aggregate.fields = nullptr;
     935                                newType->aggInst.aggregate->aggregate.body = false;
    913936                        } // if
    914937                        // don't hoist twice
     
    10511074        } // if
    10521075
     1076        if ( assert.condition ) {
     1077                return new StaticAssertDecl( maybeBuild< Expression >( assert.condition ), strict_dynamic_cast< ConstantExpr * >( maybeClone( assert.message ) ) );
     1078        }
     1079
    10531080        // SUE's cannot have function specifiers, either
    10541081        //
  • src/Parser/ExpressionNode.cc

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Mar  3 18:22:33 2018
    13 // Update Count     : 796
     12// Last Modified On : Thu Mar 22 11:57:39 2018
     13// Update Count     : 801
    1414//
    1515
     
    9494} // checkLNInt
    9595
    96 static void sepNumeric( string & str, string & units ) {
    97         string::size_type posn = str.find_first_of( "`" );
    98         if ( posn != string::npos ) {
    99                 units = "?" + str.substr( posn );                               // extract units
    100                 str.erase( posn );                                                              // remove units
    101         } // if
    102 } // sepNumeric
    103 
    10496Expression * build_constantInteger( string & str ) {
    10597        static const BasicType::Kind kind[2][6] = {
     
    108100                { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt128, },
    109101        };
    110 
    111         string units;
    112         sepNumeric( str, units );                                                       // separate constant from units
    113102
    114103        bool dec = true, Unsigned = false;                                      // decimal, unsigned constant
     
    222211        if ( Unsigned && size < 2 ) {                                           // hh or h, less than int ?
    223212                // int i = -1uh => 65535 not -1, so cast is necessary for unsigned, which unfortunately eliminates warnings for large values.
    224                 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) );
     213                ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false );
    225214        } else if ( lnth != -1 ) {                                                      // explicit length ?
    226215                if ( lnth == 5 ) {                                                              // int128 ?
    227216                        size = 5;
    228                         ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) );
     217                        ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false );
    229218                } else {
    230                         ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ) );
     219                        ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ), false );
    231220                } // if
    232221        } // if
    233222  CLEANUP:
    234         if ( units.length() != 0 ) {
    235                 ret = new UntypedExpr( new NameExpr( units ), { ret } );
    236         } // if
    237223
    238224        delete &str;                                                                            // created by lex
     
    268254        };
    269255
    270         string units;
    271         sepNumeric( str, units );                                                       // separate constant from units
    272 
    273256        bool complx = false;                                                            // real, complex
    274257        int size = 1;                                                                           // 0 => float, 1 => double, 2 => long double
     
    302285        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) );
    303286        if ( lnth != -1 ) {                                                                     // explicit length ?
    304                 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ) );
    305         } // if
    306         if ( units.length() != 0 ) {
    307                 ret = new UntypedExpr( new NameExpr( units ), { ret } );
     287                ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ), false );
    308288        } // if
    309289
     
    427407        Type * targetType = maybeMoveBuildType( decl_node );
    428408        if ( dynamic_cast< VoidType * >( targetType ) ) {
    429                 return new CastExpr( maybeMoveBuild< Expression >(expr_node) );
     409                return new CastExpr( maybeMoveBuild< Expression >(expr_node), false );
    430410        } else {
    431                 return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType );
     411                return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType, false );
    432412        } // if
    433413} // build_cast
     414
     415Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ) {
     416        return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target );
     417}
    434418
    435419Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
  • src/Parser/ParseNode.h

    r2efe4b8 r1cdfa82  
    179179
    180180Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
     181Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node );
    181182Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    182183Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
     
    246247        static DeclarationNode * newAttribute( std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
    247248        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
     249        static DeclarationNode * newStaticAssert( ExpressionNode * condition, Expression * message );
    248250
    249251        DeclarationNode();
     
    313315        Attr_t attr;
    314316
     317        struct StaticAssert_t {
     318                ExpressionNode * condition;
     319                Expression * message;
     320        };
     321        StaticAssert_t assert;
     322
    315323        BuiltinType builtin;
    316324
     
    392400
    393401Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
    394 Statement * build_switch( ExpressionNode * ctl, StatementNode * stmt );
     402Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
    395403Statement * build_case( ExpressionNode * ctl );
    396404Statement * build_default();
  • src/Parser/StatementNode.cc

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Sep  1 23:25:23 2017
    13 // Update Count     : 346
     12// Last Modified On : Thu Mar  8 14:31:32 2018
     13// Update Count     : 348
    1414//
    1515
     
    115115}
    116116
    117 Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ) {
     117Statement *build_switch( bool isSwitch, ExpressionNode *ctl, StatementNode *stmt ) {
    118118        std::list< Statement * > branches;
    119119        buildMoveList< Statement, StatementNode >( stmt, branches );
     120        if ( ! isSwitch ) {                                                                             // choose statement
     121                for ( Statement * stmt : branches ) {
     122                        CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt );
     123                        if ( ! caseStmt->stmts.empty() ) {                      // code after "case" => end of case list
     124                                CompoundStmt * block = strict_dynamic_cast< CompoundStmt * >( caseStmt->stmts.front() );
     125                                block->kids.push_back( new BranchStmt( "", BranchStmt::Break ) );
     126                        } // if
     127                } // for
     128        } // if
    120129        // branches.size() == 0 for switch (...) {}, i.e., no declaration or statements
    121130        return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches );
  • src/Parser/TypeData.cc

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 15:49:00 2018
    13 // Update Count     : 597
     12// Last Modified On : Tue Apr 17 23:00:52 2018
     13// Update Count     : 602
    1414//
    1515
     
    395395                break;
    396396          case Builtin:
    397                 os << "gcc builtin type";
     397                os << DeclarationNode::builtinTypeNames[builtintype];
    398398                break;
    399399          default:
     
    490490        switch ( td->kind ) {
    491491          case TypeData::Aggregate:
    492                 if ( ! toplevel && td->aggregate.fields ) {
     492                if ( ! toplevel && td->aggregate.body ) {
    493493                        ret = td->clone();
    494494                } // if
    495495                break;
    496496          case TypeData::Enum:
    497                 if ( ! toplevel && td->enumeration.constants ) {
     497                if ( ! toplevel && td->enumeration.body ) {
    498498                        ret = td->clone();
    499499                } // if
  • src/Parser/lex.ll

    r2efe4b8 r1cdfa82  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Sat Mar  3 18:38:16 2018
    13  * Update Count     : 640
     12 * Last Modified On : Fri Apr  6 15:16:15 2018
     13 * Update Count     : 670
    1414 */
    1515
     
    5454
    5555void rm_underscore() {
    56         // Remove underscores in numeric constant by copying the non-underscore characters to the front of the string.
     56        // SKULLDUGGERY: remove underscores (ok to shorten?)
    5757        yyleng = 0;
    58         for ( int i = 0; yytext[i] != '\0'; i += 1 ) {
    59                 if ( yytext[i] == '`' ) {
    60                         // copy user suffix
    61                         for ( ; yytext[i] != '\0'; i += 1 ) {
    62                                 yytext[yyleng] = yytext[i];
    63                                 yyleng += 1;
    64                         } // for
    65                         break;
    66                 } // if
     58        for ( int i = 0; yytext[i] != '\0'; i += 1 ) {          // copying non-underscore characters to front of string
    6759                if ( yytext[i] != '_' ) {
    6860                        yytext[yyleng] = yytext[i];
     
    7163        } // for
    7264        yytext[yyleng] = '\0';
    73 }
     65} // rm_underscore
    7466
    7567// Stop warning due to incorrectly generated flex code.
     
    9082attr_identifier "@"{identifier}
    9183
    92 user_suffix_opt ("`"{identifier})?
    93 
    9484                                // numeric constants, CFA: '_' in constant
    9585hex_quad {hex}("_"?{hex}){3}
    9686size_opt (8|16|32|64|128)?
    9787length ("ll"|"LL"|[lL]{size_opt})|("hh"|"HH"|[hH])
    98 integer_suffix_opt ("_"?(([uU]({length}?[iI]?)|([iI]{length}))|([iI]({length}?[uU]?)|([uU]{length}))|({length}([iI]?[uU]?)|([uU][iI]))|[zZ]))?{user_suffix_opt}
     88integer_suffix_opt ("_"?(([uU]({length}?[iI]?)|([iI]{length}))|([iI]({length}?[uU]?)|([uU]{length}))|({length}([iI]?[uU]?)|([uU][iI]))|[zZ]))?
    9989
    10090octal_digits ({octal})|({octal}({octal}|"_")*{octal})
     
    118108floating_length ([fFdDlL]|[lL]{floating_size})
    119109floating_suffix ({floating_length}?[iI]?)|([iI]{floating_length})
    120 floating_suffix_opt ("_"?({floating_suffix}|"DL"))?{user_suffix_opt}
     110floating_suffix_opt ("_"?({floating_suffix}|"DL"))?
    121111decimal_digits ({decimal})|({decimal}({decimal}|"_")*{decimal})
    122112floating_decimal {decimal_digits}"."{exponent}?{floating_suffix_opt}
     
    125115
    126116binary_exponent "_"?[pP]"_"?[+-]?{decimal_digits}
    127 hex_floating_suffix_opt ("_"?({floating_suffix}))?{user_suffix_opt}
     117hex_floating_suffix_opt ("_"?({floating_suffix}))?
    128118hex_floating_fraction ({hex_digits}?"."{hex_digits})|({hex_digits}".")
    129119hex_floating_constant {hex_prefix}(({hex_floating_fraction}{binary_exponent})|({hex_digits}{binary_exponent})){hex_floating_suffix_opt}
     
    208198__asm                   { KEYWORD_RETURN(ASM); }                                // GCC
    209199__asm__                 { KEYWORD_RETURN(ASM); }                                // GCC
    210 _At                             { KEYWORD_RETURN(AT); }                                 // CFA
    211200_Atomic                 { KEYWORD_RETURN(ATOMIC); }                             // C11
    212201__attribute             { KEYWORD_RETURN(ATTRIBUTE); }                  // GCC
     
    239228exception               { KEYWORD_RETURN(EXCEPTION); }                  // CFA
    240229extern                  { KEYWORD_RETURN(EXTERN); }
     230fallthrough             { KEYWORD_RETURN(FALLTHROUGH); }                // CFA
    241231fallthru                { KEYWORD_RETURN(FALLTHRU); }                   // CFA
    242 fallthrough             { KEYWORD_RETURN(FALLTHROUGH); }                // CFA
    243232finally                 { KEYWORD_RETURN(FINALLY); }                    // CFA
    244233float                   { KEYWORD_RETURN(FLOAT); }
     
    270259__builtin_offsetof { KEYWORD_RETURN(OFFSETOF); }                // GCC
    271260one_t                   { NUMERIC_RETURN(ONE_T); }                              // CFA
     261or                              { QKEYWORD_RETURN(WOR); }                               // CFA
    272262otype                   { KEYWORD_RETURN(OTYPE); }                              // CFA
    273263register                { KEYWORD_RETURN(REGISTER); }
     
    306296__volatile__    { KEYWORD_RETURN(VOLATILE); }                   // GCC
    307297waitfor                 { KEYWORD_RETURN(WAITFOR); }
    308 or                              { QKEYWORD_RETURN(WOR); }                               // CFA
    309298when                    { KEYWORD_RETURN(WHEN); }
    310299while                   { KEYWORD_RETURN(WHILE); }
     
    314303                                /* identifier */
    315304{identifier}    { IDENTIFIER_RETURN(); }
     305"`"{identifier}"`" {                                                                    // CFA
     306        yytext[yyleng - 1] = '\0'; yytext += 1;                         // SKULLDUGGERY: remove backquotes (ok to shorten?)
     307        IDENTIFIER_RETURN();
     308}
    316309{attr_identifier} { ATTRIBUTE_RETURN(); }
    317 "`"                             { BEGIN BKQUOTE; }
    318 <BKQUOTE>{identifier} { IDENTIFIER_RETURN(); }
    319 <BKQUOTE>"`"    { BEGIN 0; }
    320310
    321311                                /* numeric constants */
     
    332322({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new string( yytext, yyleng ); }
    333323<QUOTE>[^'\\\n]* { strtext->append( yytext, yyleng ); }
    334 <QUOTE>['\n]{user_suffix_opt}   { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); }
     324<QUOTE>['\n]    { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); }
    335325                                /* ' stop editor highlighting */
    336326
     
    338328({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new string( yytext, yyleng ); }
    339329<STRING>[^"\\\n]* { strtext->append( yytext, yyleng ); }
    340 <STRING>["\n]{user_suffix_opt}  { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); }
     330<STRING>["\n]   { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); }
    341331                                /* " stop editor highlighting */
    342332
     
    348338                                /* punctuation */
    349339"@"                             { ASCIIOP_RETURN(); }
     340"`"                             { ASCIIOP_RETURN(); }
    350341"["                             { ASCIIOP_RETURN(); }
    351342"]"                             { ASCIIOP_RETURN(); }
     
    412403"?"({op_unary_pre_post}|"()"|"[?]"|"{}") { IDENTIFIER_RETURN(); }
    413404"^?{}"                  { IDENTIFIER_RETURN(); }
    414 "?`"{identifier} { IDENTIFIER_RETURN(); }                               // unit operator
     405"?`"{identifier} { IDENTIFIER_RETURN(); }                               // postfix operator
    415406"?"{op_binary_over}"?"  { IDENTIFIER_RETURN(); }                // binary
    416407        /*
  • src/Parser/parser.yy

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 17:48:54 2018
    13 // Update Count     : 3028
     12// Last Modified On : Tue Apr 17 17:10:30 2018
     13// Update Count     : 3144
    1414//
    1515
     
    126126        } // if
    127127} // rebindForall
     128
     129NameExpr * build_postfix_name( const string * name ) {
     130        NameExpr * new_name = build_varref( new string( "?`" + *name ) );
     131        delete name;
     132        return new_name;
     133} // build_postfix_name
    128134
    129135bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
     
    254260%type<sn> statement_decl                                statement_decl_list                     statement_list_nodecl
    255261%type<sn> selection_statement
    256 %type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
     262%type<sn> switch_clause_list_opt                switch_clause_list
    257263%type<en> case_value
    258264%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    259 %type<sn> fall_through                                  fall_through_opt
    260265%type<sn> iteration_statement                   jump_statement
    261266%type<sn> expression_statement                  asm_statement
     
    386391%precedence '('
    387392
    388 %locations                      // support location tracking for error messages
     393%locations                                                                                              // support location tracking for error messages
    389394
    390395%start translation_unit                                                                 // parse-tree root
     
    481486        | '(' compound_statement ')'                                            // GCC, lambda expression
    482487                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
     488        | constant '`' IDENTIFIER                                                       // CFA, postfix call
     489                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     490        | string_literal '`' IDENTIFIER                                         // CFA, postfix call
     491                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }
     492        | IDENTIFIER '`' IDENTIFIER                                                     // CFA, postfix call
     493                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); }
     494        | tuple '`' IDENTIFIER                                                          // CFA, postfix call
     495                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     496        | '(' comma_expression ')' '`' IDENTIFIER                       // CFA, postfix call
     497                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
    483498        | type_name '.' no_attr_identifier                                      // CFA, nested type
    484                 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
     499                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
    485500        | type_name '.' '[' push field_list pop ']'                     // CFA, nested type / tuple field selector
    486                 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
     501                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
    487502        | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
    488                 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME
     503                { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; }
    489504        ;
    490505
     
    535550        | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal
    536551                { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }
     552        | '(' type_no_function ')' '@' '{' initializer_list comma_opt '}' // CFA, explicit C compound-literal
     553                { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
    537554        | '^' primary_expression '{' argument_expression_list '}' // CFA
    538555                {
     
    670687        | '(' type_no_function ')' cast_expression
    671688                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     689        | '(' COROUTINE '&' ')' cast_expression                         // CFA
     690                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }
     691        | '(' THREAD '&' ')' cast_expression                            // CFA
     692                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); }
     693        | '(' MONITOR '&' ')' cast_expression                           // CFA
     694                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); }
    672695                // VIRTUAL cannot be opt because of look ahead issues
    673         | '(' VIRTUAL ')' cast_expression
     696        | '(' VIRTUAL ')' cast_expression                                       // CFA
    674697                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); }
    675         | '(' VIRTUAL type_no_function ')' cast_expression
     698        | '(' VIRTUAL type_no_function ')' cast_expression      // CFA
    676699                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $5 ), maybeMoveBuildType( $3 ) ) ); }
    677700//      | '(' type_no_function ')' tuple
     
    765788        | logical_OR_expression '?' comma_expression ':' conditional_expression
    766789                { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    767                 // FIX ME: this hack computes $1 twice
     790                // FIX ME: computes $1 twice
    768791        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    769792                { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
     
    780803                { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); }
    781804        | unary_expression '=' '{' initializer_list comma_opt '}'
    782                 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME
     805                { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; }
    783806        ;
    784807
     
    850873        | exception_statement
    851874        | enable_disable_statement
    852                 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
     875                { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; }
    853876        | asm_statement
    854877        ;
     
    917940                { $$ = new StatementNode( build_if( $4, $6, $8 ) ); }
    918941        | SWITCH '(' comma_expression ')' case_clause
    919                 { $$ = new StatementNode( build_switch( $3, $5 ) ); }
     942                { $$ = new StatementNode( build_switch( true, $3, $5 ) ); }
    920943        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    921944                {
    922                         StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
     945                        StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) );
    923946                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    924947                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    929952                }
    930953        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    931                 { $$ = new StatementNode( build_switch( $3, $5 ) ); }
    932         | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
    933                 {
    934                         StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
     954                { $$ = new StatementNode( build_switch( false, $3, $5 ) ); }
     955        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
     956                {
     957                        StatementNode *sw = new StatementNode( build_switch( false, $3, $8 ) );
    935958                        $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    936959                }
     
    970993        ;
    971994
     995//label_list_opt:
     996//      // empty
     997//      | identifier_or_type_name ':'
     998//      | label_list_opt identifier_or_type_name ':'
     999//      ;
     1000
    9721001case_label_list:                                                                                // CFA
    9731002        case_label
     
    9901019        | switch_clause_list case_label_list statement_list_nodecl
    9911020                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
    992         ;
    993 
    994 choose_clause_list_opt:                                                                 // CFA
    995         // empty
    996                 { $$ = nullptr; }
    997         | choose_clause_list
    998         ;
    999 
    1000 choose_clause_list:                                                                             // CFA
    1001         case_label_list fall_through
    1002                 { $$ = $1->append_last_case( $2 ); }
    1003         | case_label_list statement_list_nodecl fall_through_opt
    1004                 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); }
    1005         | choose_clause_list case_label_list fall_through
    1006                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); }
    1007         | choose_clause_list case_label_list statement_list_nodecl fall_through_opt
    1008                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); }
    1009         ;
    1010 
    1011 fall_through_opt:                                                                               // CFA
    1012         // empty
    1013                 { $$ = new StatementNode( build_branch( BranchStmt::Break ) ); } // insert implicit break
    1014         | fall_through
    1015         ;
    1016 
    1017 fall_through_name:                                                                              // CFA
    1018         FALLTHRU
    1019         | FALLTHROUGH
    1020         ;
    1021 
    1022 fall_through:                                                                                   // CFA
    1023         fall_through_name
    1024                 { $$ = nullptr; }
    1025         | fall_through_name ';'
    1026                 { $$ = nullptr; }
    10271021        ;
    10281022
     
    10501044                // whereas normal operator precedence yields goto (*i)+3;
    10511045                { $$ = new StatementNode( build_computedgoto( $3 ) ); }
     1046                // A semantic check is required to ensure fallthru appears only in the body of a choose statement.
     1047    | fall_through_name ';'                                                             // CFA
     1048                { $$ = new StatementNode( build_branch( BranchStmt::FallThrough ) ); }
     1049    | fall_through_name identifier_or_type_name ';'             // CFA
     1050                { $$ = new StatementNode( build_branch( $2, BranchStmt::FallThrough ) ); }
     1051        | fall_through_name DEFAULT ';'                                         // CFA
     1052                { $$ = new StatementNode( build_branch( BranchStmt::FallThroughDefault ) ); }
    10521053        | CONTINUE ';'
    10531054                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
     
    10671068                { $$ = new StatementNode( build_return( $2 ) ); }
    10681069        | RETURN '{' initializer_list comma_opt '}'
    1069                 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1070                { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; }
    10701071        | THROW assignment_expression_opt ';'                           // handles rethrow
    10711072                { $$ = new StatementNode( build_throw( $2 ) ); }
     
    10761077        ;
    10771078
     1079fall_through_name:                                                                              // CFA
     1080        FALLTHRU
     1081        | FALLTHROUGH
     1082        ;
     1083
    10781084with_statement:
    10791085        WITH '(' tuple_expression_list ')' statement
     
    10861092mutex_statement:
    10871093        MUTEX '(' argument_expression_list ')' statement
    1088                 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1094                { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; }
    10891095        ;
    10901096
    10911097when_clause:
    1092         WHEN '(' comma_expression ')'
    1093                 { $$ = $3; }
     1098        WHEN '(' comma_expression ')'                           { $$ = $3; }
    10941099        ;
    10951100
     
    11151120
    11161121timeout:
    1117         TIMEOUT '(' comma_expression ')'
    1118                 { $$ = $3; }
     1122        TIMEOUT '(' comma_expression ')'                        { $$ = $3; }
    11191123        ;
    11201124
     
    11591163        //empty
    11601164                { $$ = nullptr; }
    1161         | ';' conditional_expression
    1162                 { $$ = $2; }
     1165        | ';' conditional_expression                            { $$ = $2; }
    11631166        ;
    11641167
    11651168handler_key:
    1166         CATCH
    1167                 { $$ = CatchStmt::Terminate; }
    1168         | CATCHRESUME
    1169                 { $$ = CatchStmt::Resume; }
     1169        CATCH                                                                           { $$ = CatchStmt::Terminate; }
     1170        | CATCHRESUME                                                           { $$ = CatchStmt::Resume; }
    11701171        ;
    11711172
    11721173finally_clause:
    1173         FINALLY compound_statement
    1174                 {
    1175                         $$ = new StatementNode( build_finally( $2 ) );
    1176                 }
     1174        FINALLY compound_statement                                      { $$ = new StatementNode( build_finally( $2 ) ); }
    11771175        ;
    11781176
     
    13161314static_assert:
    13171315        STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11
    1318                 { SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1316                { $$ = DeclarationNode::newStaticAssert( $3, $5 ); }
    13191317
    13201318// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
     
    17101708        | LONG
    17111709                { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }
    1712         | ZERO_T
    1713                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
    1714         | ONE_T
    1715                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    17161710        | VALIST                                                                                        // GCC, __builtin_va_list
    17171711                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
     
    17331727basic_type_specifier:
    17341728        direct_type
     1729                // Cannot have type modifiers, e.g., short, long, etc.
    17351730        | type_qualifier_list_opt indirect_type type_qualifier_list_opt
    17361731                { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); }
     
    17381733
    17391734direct_type:
    1740                 // A semantic check is necessary for conflicting type qualifiers.
    17411735        basic_type_name
    17421736        | type_qualifier_list basic_type_name
     
    17571751        | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type(a+b) y;
    17581752                { $$ = DeclarationNode::newAttr( $1, $3 ); }
     1753        | ZERO_T                                                                                        // CFA
     1754                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
     1755        | ONE_T                                                                                         // CFA
     1756                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    17591757        ;
    17601758
     
    24132411                        $$ = $2;
    24142412                }
    2415         | forall '{' external_definition_list '}'                       // CFA, namespace
     2413        | type_qualifier_list '{' external_definition_list '}'                  // CFA, namespace
    24162414        ;
    24172415
  • src/ResolvExpr/AlternativeFinder.cc

    r2efe4b8 r1cdfa82  
    12381238        }
    12391239
    1240         Expression * restructureCast( Expression * argExpr, Type * toType ) {
     1240        Expression * restructureCast( Expression * argExpr, Type * toType, bool isGenerated ) {
    12411241                if ( argExpr->get_result()->size() > 1 && ! toType->isVoid() && ! dynamic_cast<ReferenceType *>( toType ) ) {
    12421242                        // Argument expression is a tuple and the target type is not void and not a reference type.
     
    12531253                                // cast each component
    12541254                                TupleIndexExpr * idx = new TupleIndexExpr( argExpr->clone(), i );
    1255                                 componentExprs.push_back( restructureCast( idx, toType->getComponent( i ) ) );
     1255                                componentExprs.push_back( restructureCast( idx, toType->getComponent( i ), isGenerated ) );
    12561256                        }
    12571257                        assert( componentExprs.size() > 0 );
     
    12601260                } else {
    12611261                        // handle normally
    1262                         return new CastExpr( argExpr, toType->clone() );
     1262                        CastExpr * ret = new CastExpr( argExpr, toType->clone() );
     1263                        ret->isGenerated = isGenerated;
     1264                        return ret;
    12631265                }
    12641266        }
     
    13041306                                // count one safe conversion for each value that is thrown away
    13051307                                thisCost.incSafe( discardedValues );
    1306                                 Alternative newAlt( restructureCast( alt.expr->clone(), toType ), alt.env,
     1308                                Alternative newAlt( restructureCast( alt.expr->clone(), toType, castExpr->isGenerated ), alt.env,
    13071309                                        alt.cost, thisCost );
    13081310                                inferParameters( needAssertions, haveAssertions, newAlt, openVars,
     
    17271729                                        // count one safe conversion for each value that is thrown away
    17281730                                        thisCost.incSafe( discardedValues );
    1729                                         Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost );
     1731                                        Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType, true ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost );
    17301732                                        inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) );
    17311733                                }
  • src/ResolvExpr/CommonType.cc

    r2efe4b8 r1cdfa82  
    2828
    2929// #define DEBUG
     30#ifdef DEBUG
     31#define PRINT(x) x
     32#else
     33#define PRINT(x)
     34#endif
    3035
    3136namespace ResolvExpr {
     
    7075                // need unify to bind type variables
    7176                if ( unify( t1, t2, env, have, need, newOpen, indexer, common ) ) {
    72                         // std::cerr << "unify success: " << widenFirst << " " << widenSecond << std::endl;
     77                        PRINT(
     78                                std::cerr << "unify success: " << widenFirst << " " << widenSecond << std::endl;
     79                        )
    7380                        if ( (widenFirst || t2->get_qualifiers() <= t1->get_qualifiers()) && (widenSecond || t1->get_qualifiers() <= t2->get_qualifiers()) ) {
    74                                 // std::cerr << "widen okay" << std::endl;
     81                                PRINT(
     82                                        std::cerr << "widen okay" << std::endl;
     83                                )
    7584                                common->get_qualifiers() |= t1->get_qualifiers();
    7685                                common->get_qualifiers() |= t2->get_qualifiers();
     
    7887                        }
    7988                }
    80                 // std::cerr << "exact unify failed: " << t1 << " " << t2 << std::endl;
     89                PRINT(
     90                        std::cerr << "exact unify failed: " << t1 << " " << t2 << std::endl;
     91                )
    8192                return nullptr;
    8293        }
     
    90101                        int diff = depth1-depth2;
    91102                        // TODO: should it be possible for commonType to generate complicated conversions? I would argue no, only conversions that involve types of the same reference level or a difference of 1 should be allowed.
    92                         if ( diff > 1 || diff < -1 ) return nullptr;
     103                        // if ( diff > 1 || diff < -1 ) return nullptr;
    93104
    94105                        // special case where one type has a reference depth of 1 larger than the other
    95106                        if ( diff > 0 || diff < 0 ) {
    96                                 // std::cerr << "reference depth diff: " << diff << std::endl;
     107                                PRINT(
     108                                        std::cerr << "reference depth diff: " << diff << std::endl;
     109                                )
    97110                                Type * result = nullptr;
    98111                                ReferenceType * ref1 = dynamic_cast< ReferenceType * >( type1 );
     
    109122                                if ( result && ref1 ) {
    110123                                        // formal is reference, so result should be reference
    111                                         // std::cerr << "formal is reference; result should be reference" << std::endl;
     124                                        PRINT(
     125                                                std::cerr << "formal is reference; result should be reference" << std::endl;
     126                                        )
    112127                                        result = new ReferenceType( ref1->get_qualifiers(), result );
    113128                                }
    114                                 // std::cerr << "common type of reference [" << type1 << "] and [" << type2 << "] is [" << result << "]" << std::endl;
     129                                PRINT(
     130                                        std::cerr << "common type of reference [" << type1 << "] and [" << type2 << "] is [" << result << "]" << std::endl;
     131                                )
    115132                                return result;
    116133                        }
  • src/ResolvExpr/ConversionCost.cc

    r2efe4b8 r1cdfa82  
    276276                        // xxx - not positive this is correct, but appears to allow casting int => enum
    277277                        cost = Cost::unsafe;
    278                 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) {
    279                         cost = Cost::unsafe;
    280                 } // if
     278                } // if
     279                // no cases for zero_t/one_t because it should not be possible to convert int, etc. to zero_t/one_t.
    281280        }
    282281
     
    310309                                // assignResult == 0 means Cost::Infinity
    311310                        } // if
    312                 } else if ( dynamic_cast< ZeroType * >( dest ) ) {
    313                         cost = Cost::unsafe;
     311                        // case case for zero_t because it should not be possible to convert pointers to zero_t.
    314312                } // if
    315313        }
  • src/ResolvExpr/Resolver.cc

    r2efe4b8 r1cdfa82  
    6060                void previsit( TypeDecl *typeDecl );
    6161                void previsit( EnumDecl * enumDecl );
     62                void previsit( StaticAssertDecl * assertDecl );
    6263
    6364                void previsit( ArrayType * at );
     
    365366        }
    366367
     368        void Resolver::previsit( StaticAssertDecl * assertDecl ) {
     369                findIntegralExpression( assertDecl->condition, indexer );
     370        }
     371
    367372        void Resolver::previsit( ExprStmt *exprStmt ) {
    368373                visit_children = false;
  • src/SymTab/Indexer.cc

    r2efe4b8 r1cdfa82  
    501501
    502502        bool addedDeclConflicts( AggregateDecl *existing, AggregateDecl *added ) {
    503                 if ( existing->get_members().empty() ) {
     503                if ( ! existing->body ) {
    504504                        return false;
    505                 } else if ( ! added->get_members().empty() ) {
     505                } else if ( added->body ) {
    506506                        SemanticError( added, "redeclaration of " );
    507507                } // if
  • src/SymTab/Validate.cc

    r2efe4b8 r1cdfa82  
    9090                void previsit( StructDecl * aggregateDecl );
    9191                void previsit( UnionDecl * aggregateDecl );
     92                void previsit( StaticAssertDecl * assertDecl );
    9293
    9394          private:
     
    148149                void previsit( ObjectDecl * object );
    149150                void previsit( FunctionDecl * func );
     151                void previsit( FunctionType * ftype );
    150152                void previsit( StructDecl * aggrDecl );
    151153                void previsit( UnionDecl * aggrDecl );
     
    296298        }
    297299
    298         bool isStructOrUnion( Declaration *decl ) {
    299                 return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl );
     300        bool shouldHoist( Declaration *decl ) {
     301                return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl ) || dynamic_cast< StaticAssertDecl * >( decl );
    300302        }
    301303
     
    310312                } // if
    311313                // Always remove the hoisted aggregate from the inner structure.
    312                 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, isStructOrUnion ); } );
     314                GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, shouldHoist, false ); } );
    313315        }
    314316
    315317        void HoistStruct::previsit( EnumInstType * inst ) {
    316                 if ( inst->baseEnum ) {
     318                if ( inst->baseEnum && inst->baseEnum->body ) {
    317319                        declsToAddBefore.push_front( inst->baseEnum );
    318320                }
     
    320322
    321323        void HoistStruct::previsit( StructInstType * inst ) {
    322                 if ( inst->baseStruct ) {
     324                if ( inst->baseStruct && inst->baseStruct->body ) {
    323325                        declsToAddBefore.push_front( inst->baseStruct );
    324326                }
     
    326328
    327329        void HoistStruct::previsit( UnionInstType * inst ) {
    328                 if ( inst->baseUnion ) {
     330                if ( inst->baseUnion && inst->baseUnion->body ) {
    329331                        declsToAddBefore.push_front( inst->baseUnion );
     332                }
     333        }
     334
     335        void HoistStruct::previsit( StaticAssertDecl * assertDecl ) {
     336                if ( parentAggr ) {
     337                        declsToAddBefore.push_back( assertDecl );
    330338                }
    331339        }
     
    623631
    624632        void ForallPointerDecay::previsit( ObjectDecl *object ) {
    625                 forallFixer( object->type->forall, object );
    626                 if ( PointerType *pointer = dynamic_cast< PointerType * >( object->type ) ) {
    627                         forallFixer( pointer->base->forall, object );
    628                 } // if
     633                // ensure that operator names only apply to functions or function pointers
     634                if ( CodeGen::isOperator( object->name ) && ! dynamic_cast< FunctionType * >( object->type->stripDeclarator() ) ) {
     635                        SemanticError( object->location, toCString( "operator ", object->name.c_str(), " is not a function or function pointer." ) );
     636                }
    629637                object->fixUniqueId();
    630638        }
    631639
    632640        void ForallPointerDecay::previsit( FunctionDecl *func ) {
    633                 forallFixer( func->type->forall, func );
    634641                func->fixUniqueId();
     642        }
     643
     644        void ForallPointerDecay::previsit( FunctionType * ftype ) {
     645                forallFixer( ftype->forall, ftype );
    635646        }
    636647
     
    681692                                new_static_root<BasicType>( Type::Qualifiers(), BasicType::LongUnsignedInt );
    682693                }
    683                 filter( translationUnit, isTypedef );
     694                filter( translationUnit, isTypedef, true );
    684695        }
    685696
     
    818829                        } // if
    819830                        return false;
    820                 } );
     831                }, true);
    821832                return compoundStmt;
    822833        }
     
    826837        template<typename AggDecl>
    827838        AggDecl *EliminateTypedef::handleAggregate( AggDecl * aggDecl ) {
    828                 filter( aggDecl->members, isTypedef );
     839                filter( aggDecl->members, isTypedef, true );
    829840                return aggDecl;
    830841        }
  • src/SynTree/CompoundStmt.cc

    r2efe4b8 r1cdfa82  
    2323#include "Statement.h"                // for CompoundStmt, Statement, DeclStmt
    2424#include "SynTree/Label.h"            // for Label
    25 #include "SynTree/VarExprReplacer.h"  // for VarExprReplacer, VarExprReplace...
     25#include "SynTree/DeclReplacer.h"     // for DeclReplacer
    2626
    2727using std::string;
     
    4949        // recursively execute this routine. There may be more efficient ways of doing
    5050        // this.
    51         VarExprReplacer::DeclMap declMap;
     51        DeclReplacer::DeclMap declMap;
    5252        std::list< Statement * >::const_iterator origit = other.kids.begin();
    5353        for ( Statement * s : kids ) {
     
    6464        }
    6565        if ( ! declMap.empty() ) {
    66                 VarExprReplacer::replace( this, declMap );
     66                DeclReplacer::replace( this, declMap );
    6767        }
    6868}
  • src/SynTree/Declaration.cc

    r2efe4b8 r1cdfa82  
    7474
    7575
     76StaticAssertDecl::StaticAssertDecl( Expression * condition, ConstantExpr * message ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), condition( condition ), message( message )  {
     77}
     78
     79StaticAssertDecl::StaticAssertDecl( const StaticAssertDecl & other ) : Declaration( other ), condition( maybeClone( other.condition ) ), message( maybeClone( other.message ) )  {
     80}
     81
     82StaticAssertDecl::~StaticAssertDecl() {
     83        delete condition;
     84        delete message;
     85}
     86
     87void StaticAssertDecl::print( std::ostream &os, Indenter indent ) const {
     88        os << "Static Assert with condition: ";
     89        condition->print( os, indent+1 );
     90        os << std::endl << indent << "and message: ";
     91        message->print( os, indent+1 );
     92os << std::endl;
     93}
     94
     95void StaticAssertDecl::printShort( std::ostream &os, Indenter indent ) const {
     96        print( os, indent );
     97}
     98
    7699// Local Variables: //
    77100// tab-width: 4 //
  • src/SynTree/Declaration.h

    r2efe4b8 r1cdfa82  
    357357};
    358358
     359class StaticAssertDecl : public Declaration {
     360public:
     361        Expression * condition;
     362        ConstantExpr * message;   // string literal
     363
     364        StaticAssertDecl( Expression * condition, ConstantExpr * message );
     365        StaticAssertDecl( const StaticAssertDecl & other );
     366        virtual ~StaticAssertDecl();
     367
     368        virtual StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); }
     369        virtual void accept( Visitor &v ) override { v.visit( this ); }
     370        virtual StaticAssertDecl * acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     371        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
     372        virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     373};
     374
    359375std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data );
    360376
  • src/SynTree/Expression.cc

    r2efe4b8 r1cdfa82  
    238238}
    239239
    240 CastExpr::CastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
     240CastExpr::CastExpr( Expression *arg, Type *toType, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) {
    241241        set_result(toType);
    242242}
    243243
    244 CastExpr::CastExpr( Expression *arg_ ) : Expression(), arg(arg_) {
     244CastExpr::CastExpr( Expression *arg, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) {
    245245        set_result( new VoidType( Type::Qualifiers() ) );
    246246}
    247247
    248 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
     248CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
    249249}
    250250
     
    259259                result->print( os, indent+1 );
    260260        } // if
     261        Expression::print( os, indent );
     262}
     263
     264KeywordCastExpr::KeywordCastExpr( Expression *arg, Target target ) : Expression(), arg(arg), target( target ) {
     265}
     266
     267KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) {
     268}
     269
     270KeywordCastExpr::~KeywordCastExpr() {
     271        delete arg;
     272}
     273
     274const std::string & KeywordCastExpr::targetString() const {
     275        static const std::string targetStrs[] = {
     276                "coroutine", "thread", "monitor"
     277        };
     278        static_assert(
     279                (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS),
     280                "Each KeywordCastExpr::Target should have a corresponding string representation"
     281        );
     282        return targetStrs[(unsigned long)target];
     283}
     284
     285void KeywordCastExpr::print( std::ostream &os, Indenter indent ) const {
     286        os << "Keyword Cast of:" << std::endl << indent+1;
     287        arg->print(os, indent+1);
     288        os << std::endl << indent << "... to: ";
     289        os << targetString();
    261290        Expression::print( os, indent );
    262291}
  • src/SynTree/Expression.h

    r2efe4b8 r1cdfa82  
    184184  public:
    185185        Expression * arg;
    186 
    187         CastExpr( Expression * arg );
    188         CastExpr( Expression * arg, Type * toType );
     186        bool isGenerated = true; // whether this cast appeared in the source program
     187
     188        CastExpr( Expression * arg, bool isGenerated = true );
     189        CastExpr( Expression * arg, Type * toType, bool isGenerated = true );
     190        CastExpr( Expression * arg, void * ) = delete; // prevent accidentally passing pointers for isGenerated in the first constructor
    189191        CastExpr( const CastExpr & other );
    190192
     
    193195
    194196        virtual CastExpr * clone() const { return new CastExpr( * this ); }
     197        virtual void accept( Visitor & v ) { v.visit( this ); }
     198        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     199        virtual void print( std::ostream & os, Indenter indent = {} ) const;
     200};
     201
     202/// KeywordCastExpr represents a cast to 'keyword types', e.g. (thread &)t
     203class KeywordCastExpr : public Expression {
     204public:
     205        Expression * arg;
     206        enum Target {
     207                Coroutine, Thread, Monitor, NUMBER_OF_TARGETS
     208        } target;
     209
     210        KeywordCastExpr( Expression * arg, Target target );
     211        KeywordCastExpr( const KeywordCastExpr & other );
     212        virtual ~KeywordCastExpr();
     213
     214        const std::string & targetString() const;
     215
     216        virtual KeywordCastExpr * clone() const { return new KeywordCastExpr( * this ); }
    195217        virtual void accept( Visitor & v ) { v.visit( this ); }
    196218        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
  • src/SynTree/FunctionDecl.cc

    r2efe4b8 r1cdfa82  
    2626#include "Statement.h"           // for CompoundStmt
    2727#include "Type.h"                // for Type, FunctionType, Type::FuncSpecif...
    28 #include "VarExprReplacer.h"
     28#include "DeclReplacer.h"
    2929
    3030extern bool translation_unit_nomain;
     
    4141                : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
    4242
    43         VarExprReplacer::DeclMap declMap;
     43        DeclReplacer::DeclMap declMap;
    4444        for ( auto p : group_iterate( other.type->parameters, type->parameters ) ) {
    4545                declMap[ std::get<0>(p) ] = std::get<1>(p);
     
    4949        }
    5050        if ( ! declMap.empty() ) {
    51                 VarExprReplacer::replace( this, declMap );
     51                DeclReplacer::replace( this, declMap );
    5252        }
    5353        cloneAll( other.withExprs, withExprs );
  • src/SynTree/Mutator.h

    r2efe4b8 r1cdfa82  
    3434        virtual Declaration * mutate( TypedefDecl * typeDecl ) = 0;
    3535        virtual AsmDecl * mutate( AsmDecl * asmDecl ) = 0;
     36        virtual StaticAssertDecl * mutate( StaticAssertDecl * assertDecl ) = 0;
    3637
    3738        virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ) = 0;
     
    5859        virtual Expression * mutate( UntypedExpr * untypedExpr ) = 0;
    5960        virtual Expression * mutate( NameExpr * nameExpr ) = 0;
    60         virtual Expression * mutate( AddressExpr * castExpr ) = 0;
     61        virtual Expression * mutate( AddressExpr * addrExpr ) = 0;
    6162        virtual Expression * mutate( LabelAddressExpr * labAddressExpr ) = 0;
    6263        virtual Expression * mutate( CastExpr * castExpr ) = 0;
     64        virtual Expression * mutate( KeywordCastExpr * castExpr ) = 0;
    6365        virtual Expression * mutate( VirtualCastExpr * castExpr ) = 0;
    6466        virtual Expression * mutate( UntypedMemberExpr * memberExpr ) = 0;
  • src/SynTree/Statement.cc

    r2efe4b8 r1cdfa82  
    3434Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {}
    3535
    36 void Statement::print( std::ostream & os, Indenter ) const {
     36void Statement::print( std::ostream & os, Indenter indent ) const {
    3737        if ( ! labels.empty() ) {
    38                 os << "Labels: {";
     38                os << indent << "... Labels: {";
    3939                for ( const Label & l : labels ) {
    4040                        os << l << ",";
     
    188188
    189189void CaseStmt::print( std::ostream &os, Indenter indent ) const {
    190         if ( isDefault() ) os << "Default ";
     190        if ( isDefault() ) os << indent << "Default ";
    191191        else {
    192                 os << "Case ";
     192                os << indent << "Case ";
    193193                condition->print( os, indent );
    194194        } // if
     
    196196
    197197        for ( Statement * stmt : stmts ) {
     198                os << indent+1;
    198199                stmt->print( os, indent+1 );
    199200        }
     
    391392}
    392393
    393 void NullStmt::print( std::ostream &os, Indenter ) const {
     394void NullStmt::print( std::ostream &os, Indenter indent ) const {
    394395        os << "Null Statement" << endl;
     396        Statement::print( os, indent );
    395397}
    396398
  • src/SynTree/Statement.h

    r2efe4b8 r1cdfa82  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Sep  3 20:46:46 2017
    13 // Update Count     : 77
     12// Last Modified On : Thu Mar  8 14:53:02 2018
     13// Update Count     : 78
    1414//
    1515
     
    246246class BranchStmt : public Statement {
    247247  public:
    248         enum Type { Goto = 0, Break, Continue };
     248        enum Type { Goto = 0, Break, Continue, FallThrough, FallThroughDefault };
    249249
    250250        // originalTarget kept for error messages.
  • src/SynTree/SynTree.h

    r2efe4b8 r1cdfa82  
    3838class TypedefDecl;
    3939class AsmDecl;
     40class StaticAssertDecl;
    4041
    4142class Statement;
     
    6869class LabelAddressExpr;
    6970class CastExpr;
     71class KeywordCastExpr;
    7072class VirtualCastExpr;
    7173class MemberExpr;
  • src/SynTree/TypeSubstitution.cc

    r2efe4b8 r1cdfa82  
    132132                return inst;
    133133        } else {
    134 ///         std::cerr << "found " << inst->get_name() << ", replacing with ";
    135 ///         i->second->print( std::cerr );
    136 ///         std::cerr << std::endl;
     134                // cut off infinite loop for the case where a type is bound to itself.
     135                // Note: this does not prevent cycles in the general case, so it may be necessary to do something more sophisticated here.
     136                // TODO: investigate preventing type variables from being bound to themselves in the first place.
     137                if ( TypeInstType * replacement = dynamic_cast< TypeInstType * >( i->second ) ) {
     138                        if ( inst->name == replacement->name ) {
     139                                return inst;
     140                        }
     141                }
     142                // std::cerr << "found " << inst->name << ", replacing with " << i->second << std::endl;
    137143                subCount++;
    138144                Type * newtype = i->second->clone();
    139145                newtype->get_qualifiers() |= inst->get_qualifiers();
    140                 return newtype;
     146                // Note: need to recursively apply substitution to the new type because normalize does not substitute bound vars, but bound vars must be substituted when not in freeOnly mode.
     147                return newtype->acceptMutator( *visitor );
    141148        } // if
    142149}
  • src/SynTree/TypeSubstitution.h

    r2efe4b8 r1cdfa82  
    125125
    126126// definitition must happen after PassVisitor is included so that WithGuards can be used
    127 struct TypeSubstitution::Substituter : public WithGuards {
     127struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter> {
    128128                Substituter( TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {}
    129129
  • src/SynTree/Visitor.h

    r2efe4b8 r1cdfa82  
    3636        virtual void visit( TypedefDecl * typeDecl ) = 0;
    3737        virtual void visit( AsmDecl * asmDecl ) = 0;
     38        virtual void visit( StaticAssertDecl * assertDecl ) = 0;
    3839
    3940        virtual void visit( CompoundStmt * compoundStmt ) = 0;
     
    6162        virtual void visit( NameExpr * nameExpr ) = 0;
    6263        virtual void visit( CastExpr * castExpr ) = 0;
     64        virtual void visit( KeywordCastExpr * castExpr ) = 0;
    6365        virtual void visit( VirtualCastExpr * castExpr ) = 0;
    6466        virtual void visit( AddressExpr * addressExpr ) = 0;
  • src/SynTree/module.mk

    r2efe4b8 r1cdfa82  
    4949       SynTree/Attribute.cc \
    5050       SynTree/BaseSyntaxNode.cc \
    51        SynTree/VarExprReplacer.cc
     51       SynTree/DeclReplacer.cc
    5252
  • src/benchmark/bench.h

    r2efe4b8 r1cdfa82  
    1010#if defined(__cforall)
    1111}
    12 #include <bits/cfatime.h>
     12//#include <bits/cfatime.h>
    1313#endif
    1414
  • src/libcfa/Makefile.am

    r2efe4b8 r1cdfa82  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Fri Feb  9 15:51:24 2018
    14 ## Update Count     : 223
     13## Last Modified On : Thu Apr 12 14:38:34 2018
     14## Update Count     : 231
    1515###############################################################################
    1616
     
    4646CC = ${abs_top_srcdir}/src/driver/cfa
    4747
    48 headers = fstream iostream iterator limits rational stdlib \
     48headers = fstream iostream iterator limits rational time stdlib \
    4949          containers/maybe containers/pair containers/result containers/vector
    5050
     
    100100        math                            \
    101101        gmp                             \
     102        time_t.h                        \
     103        clock                   \
    102104        bits/align.h            \
    103         bits/cfatime.h          \
    104105        bits/containers.h               \
    105106        bits/defs.h             \
  • src/libcfa/Makefile.in

    r2efe4b8 r1cdfa82  
    150150am__libcfa_d_a_SOURCES_DIST = libcfa-prelude.c interpose.c \
    151151        bits/debug.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 \
     152        rational.c time.c stdlib.c containers/maybe.c \
     153        containers/pair.c containers/result.c containers/vector.c \
    154154        concurrency/coroutine.c concurrency/thread.c \
    155155        concurrency/kernel.c concurrency/monitor.c assert.c \
     
    165165        libcfa_d_a-iostream.$(OBJEXT) libcfa_d_a-iterator.$(OBJEXT) \
    166166        libcfa_d_a-limits.$(OBJEXT) libcfa_d_a-rational.$(OBJEXT) \
    167         libcfa_d_a-stdlib.$(OBJEXT) \
     167        libcfa_d_a-time.$(OBJEXT) libcfa_d_a-stdlib.$(OBJEXT) \
    168168        containers/libcfa_d_a-maybe.$(OBJEXT) \
    169169        containers/libcfa_d_a-pair.$(OBJEXT) \
     
    184184libcfa_a_LIBADD =
    185185am__libcfa_a_SOURCES_DIST = libcfa-prelude.c interpose.c bits/debug.c \
    186         fstream.c iostream.c iterator.c limits.c rational.c stdlib.c \
    187         containers/maybe.c containers/pair.c containers/result.c \
    188         containers/vector.c concurrency/coroutine.c \
    189         concurrency/thread.c concurrency/kernel.c \
    190         concurrency/monitor.c assert.c exception.c virtual.c \
    191         concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
    192         concurrency/invoke.c concurrency/preemption.c
     186        fstream.c iostream.c iterator.c limits.c rational.c time.c \
     187        stdlib.c containers/maybe.c containers/pair.c \
     188        containers/result.c containers/vector.c \
     189        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
    193194@BUILD_CONCURRENCY_TRUE@am__objects_5 = concurrency/libcfa_a-coroutine.$(OBJEXT) \
    194195@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-thread.$(OBJEXT) \
     
    197198am__objects_6 = libcfa_a-fstream.$(OBJEXT) libcfa_a-iostream.$(OBJEXT) \
    198199        libcfa_a-iterator.$(OBJEXT) libcfa_a-limits.$(OBJEXT) \
    199         libcfa_a-rational.$(OBJEXT) libcfa_a-stdlib.$(OBJEXT) \
    200         containers/libcfa_a-maybe.$(OBJEXT) \
     200        libcfa_a-rational.$(OBJEXT) libcfa_a-time.$(OBJEXT) \
     201        libcfa_a-stdlib.$(OBJEXT) containers/libcfa_a-maybe.$(OBJEXT) \
    201202        containers/libcfa_a-pair.$(OBJEXT) \
    202203        containers/libcfa_a-result.$(OBJEXT) \
     
    260261  esac
    261262am__nobase_cfa_include_HEADERS_DIST = fstream iostream iterator limits \
    262         rational stdlib containers/maybe containers/pair \
     263        rational time stdlib containers/maybe containers/pair \
    263264        containers/result containers/vector concurrency/coroutine \
    264265        concurrency/thread concurrency/kernel concurrency/monitor \
    265         ${shell find stdhdr -type f -printf "%p "} math gmp \
    266         bits/align.h bits/cfatime.h bits/containers.h bits/defs.h \
    267         bits/debug.h bits/locks.h concurrency/invoke.h
     266        ${shell find stdhdr -type f -printf "%p "} math gmp time_t.h \
     267        clock bits/align.h bits/containers.h bits/defs.h bits/debug.h \
     268        bits/locks.h concurrency/invoke.h
    268269HEADERS = $(nobase_cfa_include_HEADERS)
    269270am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
     
    419420EXTRA_FLAGS = -g -Wall -Wno-unused-function -imacros libcfa-prelude.c @CFA_FLAGS@
    420421AM_CCASFLAGS = @CFA_FLAGS@
    421 headers = fstream iostream iterator limits rational stdlib \
     422headers = fstream iostream iterator limits rational time stdlib \
    422423        containers/maybe containers/pair containers/result \
    423424        containers/vector $(am__append_3)
     
    436437        math                            \
    437438        gmp                             \
     439        time_t.h                        \
     440        clock                   \
    438441        bits/align.h            \
    439         bits/cfatime.h          \
    440442        bits/containers.h               \
    441443        bits/defs.h             \
     
    611613@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-rational.Po@am__quote@
    612614@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-stdlib.Po@am__quote@
     615@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-time.Po@am__quote@
    613616@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-virtual.Po@am__quote@
    614617@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-assert.Po@am__quote@
     
    622625@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-rational.Po@am__quote@
    623626@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-stdlib.Po@am__quote@
     627@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-time.Po@am__quote@
    624628@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-virtual.Po@am__quote@
    625629@AMDEP_TRUE@@am__include@ @am__quote@bits/$(DEPDIR)/libcfa_a-debug.Po@am__quote@
     
    786790@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-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
    787791
     792libcfa_d_a-time.o: time.c
     793@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-time.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-time.Tpo -c -o libcfa_d_a-time.o `test -f 'time.c' || echo '$(srcdir)/'`time.c
     794@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-time.Tpo $(DEPDIR)/libcfa_d_a-time.Po
     795@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='time.c' object='libcfa_d_a-time.o' libtool=no @AMDEPBACKSLASH@
     796@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     797@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-time.o `test -f 'time.c' || echo '$(srcdir)/'`time.c
     798
     799libcfa_d_a-time.obj: time.c
     800@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-time.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-time.Tpo -c -o libcfa_d_a-time.obj `if test -f 'time.c'; then $(CYGPATH_W) 'time.c'; else $(CYGPATH_W) '$(srcdir)/time.c'; fi`
     801@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-time.Tpo $(DEPDIR)/libcfa_d_a-time.Po
     802@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='time.c' object='libcfa_d_a-time.obj' libtool=no @AMDEPBACKSLASH@
     803@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     804@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-time.obj `if test -f 'time.c'; then $(CYGPATH_W) 'time.c'; else $(CYGPATH_W) '$(srcdir)/time.c'; fi`
     805
    788806libcfa_d_a-stdlib.o: stdlib.c
    789807@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-stdlib.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-stdlib.Tpo -c -o libcfa_d_a-stdlib.o `test -f 'stdlib.c' || echo '$(srcdir)/'`stdlib.c
     
    10791097@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    10801098@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
     1099
     1100libcfa_a-time.o: time.c
     1101@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-time.o -MD -MP -MF $(DEPDIR)/libcfa_a-time.Tpo -c -o libcfa_a-time.o `test -f 'time.c' || echo '$(srcdir)/'`time.c
     1102@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-time.Tpo $(DEPDIR)/libcfa_a-time.Po
     1103@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='time.c' object='libcfa_a-time.o' libtool=no @AMDEPBACKSLASH@
     1104@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1105@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-time.o `test -f 'time.c' || echo '$(srcdir)/'`time.c
     1106
     1107libcfa_a-time.obj: time.c
     1108@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-time.obj -MD -MP -MF $(DEPDIR)/libcfa_a-time.Tpo -c -o libcfa_a-time.obj `if test -f 'time.c'; then $(CYGPATH_W) 'time.c'; else $(CYGPATH_W) '$(srcdir)/time.c'; fi`
     1109@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-time.Tpo $(DEPDIR)/libcfa_a-time.Po
     1110@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='time.c' object='libcfa_a-time.obj' libtool=no @AMDEPBACKSLASH@
     1111@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1112@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-time.obj `if test -f 'time.c'; then $(CYGPATH_W) 'time.c'; else $(CYGPATH_W) '$(srcdir)/time.c'; fi`
    10811113
    10821114libcfa_a-stdlib.o: stdlib.c
  • src/libcfa/bits/locks.h

    r2efe4b8 r1cdfa82  
    1010// Created On       : Tue Oct 31 15:14:38 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec  8 16:02:22 2017
    13 // Update Count     : 1
     12// Last Modified On : Fri Mar 30 18:18:13 2018
     13// Update Count     : 9
    1414//
    1515
     
    6464
    6565        extern void yield( unsigned int );
    66         extern thread_local struct thread_desc *    volatile this_thread;
    67         extern thread_local struct processor *      volatile this_processor;
    6866
    6967        static inline void ?{}( __spinlock_t & this ) {
     
    7674                if( result ) {
    7775                        disable_interrupts();
    78                         __cfaabi_dbg_debug_do(
    79                                 this.prev_name = caller;
    80                                 this.prev_thrd = this_thread;
    81                         )
     76                        // __cfaabi_dbg_debug_do(
     77                        //      this.prev_name = caller;
     78                        //      this.prev_thrd = TL_GET( this_thread );
     79                        // )
    8280                }
    8381                return result;
     
    107105                }
    108106                disable_interrupts();
    109                 __cfaabi_dbg_debug_do(
    110                         this.prev_name = caller;
    111                         this.prev_thrd = this_thread;
    112                 )
     107                // __cfaabi_dbg_debug_do(
     108                //      this.prev_name = caller;
     109                //      this.prev_thrd = TL_GET( this_thread );
     110                // )
    113111        }
    114112
  • src/libcfa/concurrency/alarm.c

    r2efe4b8 r1cdfa82  
    1010// Created On       : Fri Jun 2 11:31:25 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:35:18 2017
    13 // Update Count     : 1
     12// Last Modified On : Mon Apr  9 13:36:18 2018
     13// Update Count     : 61
    1414//
    1515
     
    2626#include "preemption.h"
    2727
    28 
    29 static inline void ?{}( itimerval & this, __cfa_time_t * alarm ) with( this ) {
    30         it_value.tv_sec = alarm->val / (1`cfa_s).val;                   // seconds
    31         it_value.tv_usec = max( (alarm->val % (1`cfa_s).val) / (1`cfa_us).val, 1000 ); // microseconds
    32         it_interval.tv_sec = 0;
    33         it_interval.tv_usec = 0;
    34 }
    35 
    36 static inline void ?{}( __cfa_time_t & this, timespec * curr ) {
    37         uint64_t secs  = curr->tv_sec;
    38         uint64_t nsecs = curr->tv_nsec;
    39         this.val = from_s(secs).val + nsecs;
    40 }
    41 
    4228//=============================================================================================
    4329// Clock logic
    4430//=============================================================================================
    4531
    46 __cfa_time_t __kernel_get_time() {
     32Time __kernel_get_time() {
    4733        timespec curr;
    48         clock_gettime( CLOCK_REALTIME, &curr );
    49         return (__cfa_time_t){ &curr };
     34        clock_gettime( CLOCK_MONOTONIC_RAW, &curr );            // CLOCK_REALTIME
     35        return (Time){ curr };
    5036}
    5137
    52 void __kernel_set_timer( __cfa_time_t alarm ) {
    53         itimerval val = { &alarm };
    54         setitimer( ITIMER_REAL, &val, NULL );
     38void __kernel_set_timer( Duration alarm ) {
     39        setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL );
    5540}
    5641
     
    5944//=============================================================================================
    6045
    61 void ?{}( alarm_node_t & this, thread_desc * thrd, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s ) with( this ) {
     46void ?{}( alarm_node_t & this, thread_desc * thrd, Time alarm, Duration period ) with( this ) {
    6247        this.thrd = thrd;
    6348        this.alarm = alarm;
     
    6853}
    6954
    70 void ?{}( alarm_node_t & this, processor   * proc, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s ) with( this ) {
     55void ?{}( alarm_node_t & this, processor   * proc, Time alarm, Duration period ) with( this ) {
    7156        this.proc = proc;
    7257        this.alarm = alarm;
  • src/libcfa/concurrency/alarm.h

    r2efe4b8 r1cdfa82  
    1010// Created On       : Fri Jun 2 11:31:25 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:59:27 2017
    13 // Update Count     : 3
     12// Last Modified On : Mon Mar 26 16:25:41 2018
     13// Update Count     : 11
    1414//
    1515
     
    2121#include <assert.h>
    2222
    23 #include "bits/cfatime.h"
     23#include "time"
    2424
    2525struct thread_desc;
     
    3030//=============================================================================================
    3131
    32 __cfa_time_t __kernel_get_time();
    33 void __kernel_set_timer( __cfa_time_t alarm );
     32Time __kernel_get_time();
     33void __kernel_set_timer( Duration alarm );
    3434
    3535//=============================================================================================
     
    3838
    3939struct alarm_node_t {
    40         __cfa_time_t alarm;             // time when alarm goes off
    41         __cfa_time_t period;            // if > 0 => period of alarm
     40        Time alarm;                             // time when alarm goes off
     41        Duration period;                        // if > 0 => period of alarm
    4242        alarm_node_t * next;            // intrusive link list field
    4343
     
    5353typedef alarm_node_t ** __alarm_it_t;
    5454
    55 void ?{}( alarm_node_t & this, thread_desc * thrd, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s );
    56 void ?{}( alarm_node_t & this, processor   * proc, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s );
     55void ?{}( alarm_node_t & this, thread_desc * thrd, Time alarm, Duration period );
     56void ?{}( alarm_node_t & this, processor   * proc, Time alarm, Duration period );
    5757void ^?{}( alarm_node_t & this );
    5858
  • src/libcfa/concurrency/coroutine

    r2efe4b8 r1cdfa82  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 30 07:58:29 2017
    13 // Update Count     : 3
     12// Last Modified On : Fri Mar 30 18:23:45 2018
     13// Update Count     : 8
    1414//
    1515
     
    6060}
    6161
    62 // Get current coroutine
    63 extern thread_local coroutine_desc * volatile this_coroutine;
    64 
    6562// Private wrappers for context switch and stack creation
    6663extern void CoroutineCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
     
    6966// Suspend implementation inlined for performance
    7067static inline void suspend() {
    71         coroutine_desc * src = this_coroutine;          // optimization
     68        coroutine_desc * src = TL_GET( this_coroutine );                        // optimization
    7269
    7370        assertf( src->last != 0,
     
    8683forall(dtype T | is_coroutine(T))
    8784static inline void resume(T & cor) {
    88         coroutine_desc * src = this_coroutine;          // optimization
     85        coroutine_desc * src = TL_GET( this_coroutine );                        // optimization
    8986        coroutine_desc * dst = get_coroutine(cor);
    9087
     
    111108
    112109static inline void resume(coroutine_desc * dst) {
    113         coroutine_desc * src = this_coroutine;          // optimization
     110        coroutine_desc * src = TL_GET( this_coroutine );                        // optimization
    114111
    115112        // not resuming self ?
  • src/libcfa/concurrency/coroutine.c

    r2efe4b8 r1cdfa82  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 16:10:31 2018
    13 // Update Count     : 4
     12// Last Modified On : Fri Mar 30 17:20:57 2018
     13// Update Count     : 9
    1414//
    1515
     
    9999// Wrapper for co
    100100void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
    101         verify( preemption_state.enabled || this_processor->do_terminate );
     101        verify( TL_GET( preemption_state ).enabled || TL_GET( this_processor )->do_terminate );
    102102        disable_interrupts();
    103103
     
    106106
    107107        // set new coroutine that task is executing
    108         this_coroutine = dst;
     108        TL_SET( this_coroutine, dst );
    109109
    110110        // context switch to specified coroutine
     
    117117
    118118        enable_interrupts( __cfaabi_dbg_ctx );
    119         verify( preemption_state.enabled || this_processor->do_terminate );
     119        verify( TL_GET( preemption_state ).enabled || TL_GET( this_processor )->do_terminate );
    120120} //ctxSwitchDirect
    121121
     
    172172
    173173        void __leave_coroutine(void) {
    174                 coroutine_desc * src = this_coroutine;          // optimization
     174                coroutine_desc * src = TL_GET( this_coroutine ); // optimization
    175175
    176176                assertf( src->starter != 0,
  • src/libcfa/concurrency/invoke.h

    r2efe4b8 r1cdfa82  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb  9 14:41:55 2018
    13 // Update Count     : 6
     12// Last Modified On : Fri Mar 30 22:33:59 2018
     13// Update Count     : 30
    1414//
    1515
     
    1717#include "bits/defs.h"
    1818#include "bits/locks.h"
     19
     20#define TL_GET( member ) kernelThreadData.member
     21#define TL_SET( member, value ) kernelThreadData.member = value;
    1922
    2023#ifdef __cforall
     
    3033                static inline struct thread_desc             * & get_next( struct thread_desc             & this );
    3134                static inline struct __condition_criterion_t * & get_next( struct __condition_criterion_t & this );
     35
     36                extern thread_local struct KernelThreadData {
     37                        struct coroutine_desc * volatile this_coroutine;
     38                        struct thread_desc    * volatile this_thread;
     39                        struct processor      * volatile this_processor;
     40
     41                        struct {
     42                                volatile unsigned short disable_count;
     43                                volatile bool enabled;
     44                                volatile bool in_progress;
     45                        } preemption_state;
     46                } kernelThreadData;
    3247        }
     48
     49        static inline struct coroutine_desc * volatile active_coroutine() { return TL_GET( this_coroutine ); }
     50        static inline struct thread_desc * volatile active_thread() { return TL_GET( this_thread ); }
     51        static inline struct processor * volatile active_processor() { return TL_GET( this_processor ); }
    3352        #endif
    3453
    3554        struct coStack_t {
    36                 // size of stack
    37                 size_t size;
    38 
    39                 // pointer to stack
    40                 void *storage;
    41 
    42                 // stack grows towards stack limit
    43                 void *limit;
    44 
    45                 // base of stack
    46                 void *base;
    47 
    48                 // address of cfa_context_t
    49                 void *context;
    50 
    51                 // address of top of storage
    52                 void *top;
    53 
    54                 // whether or not the user allocated the stack
    55                 bool userStack;
     55                size_t size;                                                                    // size of stack
     56                void * storage;                                                                 // pointer to stack
     57                void * limit;                                                                   // stack grows towards stack limit
     58                void * base;                                                                    // base of stack
     59                void * context;                                                                 // address of cfa_context_t
     60                void * top;                                                                             // address of top of storage
     61                bool userStack;                                                                 // whether or not the user allocated the stack
    5662        };
    5763
     
    5965
    6066        struct coroutine_desc {
    61                 // stack information of the coroutine
    62                 struct coStack_t stack;
    63 
    64                 // textual name for coroutine/task, initialized by uC++ generated code
    65                 const char *name;
    66 
    67                 // copy of global UNIX variable errno
    68                 int errno_;
    69 
    70                 // current execution status for coroutine
    71                 enum coroutine_state state;
    72 
    73                 // first coroutine to resume this one
    74                 struct coroutine_desc * starter;
    75 
    76                 // last coroutine to resume this one
    77                 struct coroutine_desc * last;
     67                struct coStack_t stack;                                                 // stack information of the coroutine
     68                const char * name;                                                              // textual name for coroutine/task, initialized by uC++ generated code
     69                int errno_;                                                                             // copy of global UNIX variable errno
     70                enum coroutine_state state;                                             // current execution status for coroutine
     71                struct coroutine_desc * starter;                                // first coroutine to resume this one
     72                struct coroutine_desc * last;                                   // last coroutine to resume this one
    7873        };
    7974
  • src/libcfa/concurrency/kernel

    r2efe4b8 r1cdfa82  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:58:39 2017
    13 // Update Count     : 2
     12// Last Modified On : Tue Apr 10 14:46:49 2018
     13// Update Count     : 10
    1414//
    1515
     
    1919
    2020#include "invoke.h"
    21 #include "bits/cfatime.h"
     21#include "time_t.h"
    2222
    2323extern "C" {
     
    4949
    5050        // Preemption rate on this cluster
    51         __cfa_time_t preemption_rate;
     51        Duration preemption_rate;
    5252};
    5353
    54 extern __cfa_time_t default_preemption();
     54extern Duration default_preemption();
    5555
    5656void ?{} (cluster & this);
  • src/libcfa/concurrency/kernel.c

    r2efe4b8 r1cdfa82  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 23:52:19 2018
    13 // Update Count     : 5
     12// Last Modified On : Mon Apr  9 16:11:46 2018
     13// Update Count     : 24
    1414//
    1515
     
    2525
    2626//CFA Includes
     27#include "time"
    2728#include "kernel_private.h"
    2829#include "preemption.h"
     
    5253// Global state
    5354
    54 thread_local coroutine_desc * volatile this_coroutine;
    55 thread_local thread_desc *    volatile this_thread;
    56 thread_local processor *      volatile this_processor;
    57 
    5855// volatile thread_local bool preemption_in_progress = 0;
    5956// volatile thread_local bool preemption_enabled = false;
    6057// volatile thread_local unsigned short disable_preempt_count = 1;
    6158
    62 volatile thread_local __cfa_kernel_preemption_state_t preemption_state = { false, false, 1 };
     59thread_local struct KernelThreadData kernelThreadData = {
     60        NULL,
     61        NULL,
     62        NULL,
     63        { 1, false, false }
     64};
    6365
    6466//-----------------------------------------------------------------------------
     
    172174                terminate(&this);
    173175                verify(this.do_terminate);
    174                 verify(this_processor != &this);
     176                verify(TL_GET( this_processor ) != &this);
    175177                P( terminated );
    176                 verify(this_processor != &this);
     178                verify(TL_GET( this_processor ) != &this);
    177179                pthread_join( kernel_thread, NULL );
    178180        }
     
    213215                        if(readyThread)
    214216                        {
    215                                 verify( !preemption_state.enabled );
     217                                verify( ! TL_GET( preemption_state ).enabled );
    216218
    217219                                runThread(this, readyThread);
    218220
    219                                 verify( !preemption_state.enabled );
     221                                verify( ! TL_GET( preemption_state ).enabled );
    220222
    221223                                //Some actions need to be taken from the kernel
     
    249251
    250252        //Update global state
    251         this_thread = dst;
     253        TL_SET( this_thread, dst );
    252254
    253255        // Context Switch to the thread
     
    257259
    258260void returnToKernel() {
    259         coroutine_desc * proc_cor = get_coroutine(this_processor->runner);
    260         coroutine_desc * thrd_cor = this_thread->curr_cor = this_coroutine;
     261        coroutine_desc * proc_cor = get_coroutine(TL_GET( this_processor )->runner);
     262        coroutine_desc * thrd_cor = TL_GET( this_thread )->curr_cor = TL_GET( this_coroutine );
    261263        ThreadCtxSwitch(thrd_cor, proc_cor);
    262264}
     
    266268void finishRunning(processor * this) with( this->finish ) {
    267269        if( action_code == Release ) {
    268                 verify( !preemption_state.enabled );
     270                verify( ! TL_GET( preemption_state ).enabled );
    269271                unlock( *lock );
    270272        }
     
    273275        }
    274276        else if( action_code == Release_Schedule ) {
    275                 verify( !preemption_state.enabled );
     277                verify( ! TL_GET( preemption_state ).enabled );
    276278                unlock( *lock );
    277279                ScheduleThread( thrd );
    278280        }
    279281        else if( action_code == Release_Multi ) {
    280                 verify( !preemption_state.enabled );
     282                verify( ! TL_GET( preemption_state ).enabled );
    281283                for(int i = 0; i < lock_count; i++) {
    282284                        unlock( *locks[i] );
     
    307309void * CtxInvokeProcessor(void * arg) {
    308310        processor * proc = (processor *) arg;
    309         this_processor = proc;
    310         this_coroutine = NULL;
    311         this_thread = NULL;
    312         preemption_state.enabled = false;
    313         preemption_state.disable_count = 1;
     311        TL_SET( this_processor, proc );
     312        TL_SET( this_coroutine, NULL );
     313        TL_SET( this_thread, NULL );
     314        TL_GET( preemption_state ).enabled = false;
     315        TL_GET( preemption_state ).disable_count = 1;
    314316        // SKULLDUGGERY: We want to create a context for the processor coroutine
    315317        // which is needed for the 2-step context switch. However, there is no reason
     
    323325
    324326        //Set global state
    325         this_coroutine = get_coroutine(proc->runner);
    326         this_thread = NULL;
     327        TL_SET( this_coroutine, get_coroutine(proc->runner) );
     328        TL_SET( this_thread, NULL );
    327329
    328330        //We now have a proper context from which to schedule threads
     
    352354
    353355void kernel_first_resume(processor * this) {
    354         coroutine_desc * src = this_coroutine;
     356        coroutine_desc * src = TL_GET( this_coroutine );
    355357        coroutine_desc * dst = get_coroutine(this->runner);
    356358
    357         verify( !preemption_state.enabled );
     359        verify( ! TL_GET( preemption_state ).enabled );
    358360
    359361        create_stack(&dst->stack, dst->stack.size);
    360362        CtxStart(&this->runner, CtxInvokeCoroutine);
    361363
    362         verify( !preemption_state.enabled );
     364        verify( ! TL_GET( preemption_state ).enabled );
    363365
    364366        dst->last = src;
     
    369371
    370372        // set new coroutine that task is executing
    371         this_coroutine = dst;
     373        TL_SET( this_coroutine, dst );
    372374
    373375        // SKULLDUGGERY normally interrupts are enable before leaving a coroutine ctxswitch.
     
    386388        src->state = Active;
    387389
    388         verify( !preemption_state.enabled );
     390        verify( ! TL_GET( preemption_state ).enabled );
    389391}
    390392
     
    392394// Scheduler routines
    393395void ScheduleThread( thread_desc * thrd ) {
    394         // if( !thrd ) return;
     396        // if( ! thrd ) return;
    395397        verify( thrd );
    396398        verify( thrd->self_cor.state != Halted );
    397399
    398         verify( !preemption_state.enabled );
     400        verify( ! TL_GET( preemption_state ).enabled );
    399401
    400402        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
    401403
    402         with( *this_processor->cltr ) {
     404        with( *TL_GET( this_processor )->cltr ) {
    403405                lock  ( ready_queue_lock __cfaabi_dbg_ctx2 );
    404406                append( ready_queue, thrd );
     
    406408        }
    407409
    408         verify( !preemption_state.enabled );
     410        verify( ! TL_GET( preemption_state ).enabled );
    409411}
    410412
    411413thread_desc * nextThread(cluster * this) with( *this ) {
    412         verify( !preemption_state.enabled );
     414        verify( ! TL_GET( preemption_state ).enabled );
    413415        lock( ready_queue_lock __cfaabi_dbg_ctx2 );
    414416        thread_desc * head = pop_head( ready_queue );
    415417        unlock( ready_queue_lock );
    416         verify( !preemption_state.enabled );
     418        verify( ! TL_GET( preemption_state ).enabled );
    417419        return head;
    418420}
     
    420422void BlockInternal() {
    421423        disable_interrupts();
    422         verify( !preemption_state.enabled );
     424        verify( ! TL_GET( preemption_state ).enabled );
    423425        returnToKernel();
    424         verify( !preemption_state.enabled );
     426        verify( ! TL_GET( preemption_state ).enabled );
    425427        enable_interrupts( __cfaabi_dbg_ctx );
    426428}
     
    428430void BlockInternal( __spinlock_t * lock ) {
    429431        disable_interrupts();
    430         this_processor->finish.action_code = Release;
    431         this_processor->finish.lock        = lock;
    432 
    433         verify( !preemption_state.enabled );
     432        TL_GET( this_processor )->finish.action_code = Release;
     433        TL_GET( this_processor )->finish.lock        = lock;
     434
     435        verify( ! TL_GET( preemption_state ).enabled );
    434436        returnToKernel();
    435         verify( !preemption_state.enabled );
     437        verify( ! TL_GET( preemption_state ).enabled );
    436438
    437439        enable_interrupts( __cfaabi_dbg_ctx );
     
    440442void BlockInternal( thread_desc * thrd ) {
    441443        disable_interrupts();
    442         this_processor->finish.action_code = Schedule;
    443         this_processor->finish.thrd        = thrd;
    444 
    445         verify( !preemption_state.enabled );
     444        TL_GET( this_processor )->finish.action_code = Schedule;
     445        TL_GET( this_processor )->finish.thrd        = thrd;
     446
     447        verify( ! TL_GET( preemption_state ).enabled );
    446448        returnToKernel();
    447         verify( !preemption_state.enabled );
     449        verify( ! TL_GET( preemption_state ).enabled );
    448450
    449451        enable_interrupts( __cfaabi_dbg_ctx );
     
    453455        assert(thrd);
    454456        disable_interrupts();
    455         this_processor->finish.action_code = Release_Schedule;
    456         this_processor->finish.lock        = lock;
    457         this_processor->finish.thrd        = thrd;
    458 
    459         verify( !preemption_state.enabled );
     457        TL_GET( this_processor )->finish.action_code = Release_Schedule;
     458        TL_GET( this_processor )->finish.lock        = lock;
     459        TL_GET( this_processor )->finish.thrd        = thrd;
     460
     461        verify( ! TL_GET( preemption_state ).enabled );
    460462        returnToKernel();
    461         verify( !preemption_state.enabled );
     463        verify( ! TL_GET( preemption_state ).enabled );
    462464
    463465        enable_interrupts( __cfaabi_dbg_ctx );
     
    466468void BlockInternal(__spinlock_t * locks [], unsigned short count) {
    467469        disable_interrupts();
    468         this_processor->finish.action_code = Release_Multi;
    469         this_processor->finish.locks       = locks;
    470         this_processor->finish.lock_count  = count;
    471 
    472         verify( !preemption_state.enabled );
     470        TL_GET( this_processor )->finish.action_code = Release_Multi;
     471        TL_GET( this_processor )->finish.locks       = locks;
     472        TL_GET( this_processor )->finish.lock_count  = count;
     473
     474        verify( ! TL_GET( preemption_state ).enabled );
    473475        returnToKernel();
    474         verify( !preemption_state.enabled );
     476        verify( ! TL_GET( preemption_state ).enabled );
    475477
    476478        enable_interrupts( __cfaabi_dbg_ctx );
     
    479481void BlockInternal(__spinlock_t * locks [], unsigned short lock_count, thread_desc * thrds [], unsigned short thrd_count) {
    480482        disable_interrupts();
    481         this_processor->finish.action_code = Release_Multi_Schedule;
    482         this_processor->finish.locks       = locks;
    483         this_processor->finish.lock_count  = lock_count;
    484         this_processor->finish.thrds       = thrds;
    485         this_processor->finish.thrd_count  = thrd_count;
    486 
    487         verify( !preemption_state.enabled );
     483        TL_GET( this_processor )->finish.action_code = Release_Multi_Schedule;
     484        TL_GET( this_processor )->finish.locks       = locks;
     485        TL_GET( this_processor )->finish.lock_count  = lock_count;
     486        TL_GET( this_processor )->finish.thrds       = thrds;
     487        TL_GET( this_processor )->finish.thrd_count  = thrd_count;
     488
     489        verify( ! TL_GET( preemption_state ).enabled );
    488490        returnToKernel();
    489         verify( !preemption_state.enabled );
     491        verify( ! TL_GET( preemption_state ).enabled );
    490492
    491493        enable_interrupts( __cfaabi_dbg_ctx );
     
    493495
    494496void LeaveThread(__spinlock_t * lock, thread_desc * thrd) {
    495         verify( !preemption_state.enabled );
    496         this_processor->finish.action_code = thrd ? Release_Schedule : Release;
    497         this_processor->finish.lock        = lock;
    498         this_processor->finish.thrd        = thrd;
     497        verify( ! TL_GET( preemption_state ).enabled );
     498        TL_GET( this_processor )->finish.action_code = thrd ? Release_Schedule : Release;
     499        TL_GET( this_processor )->finish.lock        = lock;
     500        TL_GET( this_processor )->finish.thrd        = thrd;
    499501
    500502        returnToKernel();
     
    507509// Kernel boot procedures
    508510void kernel_startup(void) {
    509         verify( !preemption_state.enabled );
     511        verify( ! TL_GET( preemption_state ).enabled );
    510512        __cfaabi_dbg_print_safe("Kernel : Starting\n");
    511513
     
    531533
    532534        //initialize the global state variables
    533         this_processor = mainProcessor;
    534         this_thread = mainThread;
    535         this_coroutine = &mainThread->self_cor;
     535        TL_SET( this_processor, mainProcessor );
     536        TL_SET( this_thread, mainThread );
     537        TL_SET( this_coroutine, &mainThread->self_cor );
    536538
    537539        // Enable preemption
     
    545547        // context. Hence, the main thread does not begin through CtxInvokeThread, like all other threads. The trick here is that
    546548        // mainThread is on the ready queue when this call is made.
    547         kernel_first_resume( this_processor );
     549        kernel_first_resume( TL_GET( this_processor ) );
    548550
    549551
     
    552554        __cfaabi_dbg_print_safe("Kernel : Started\n--------------------------------------------------\n\n");
    553555
    554         verify( !preemption_state.enabled );
     556        verify( ! TL_GET( preemption_state ).enabled );
    555557        enable_interrupts( __cfaabi_dbg_ctx );
    556         verify( preemption_state.enabled );
     558        verify( TL_GET( preemption_state ).enabled );
    557559}
    558560
     
    560562        __cfaabi_dbg_print_safe("\n--------------------------------------------------\nKernel : Shutting down\n");
    561563
    562         verify( preemption_state.enabled );
     564        verify( TL_GET( preemption_state ).enabled );
    563565        disable_interrupts();
    564         verify( !preemption_state.enabled );
     566        verify( ! TL_GET( preemption_state ).enabled );
    565567
    566568        // SKULLDUGGERY: Notify the mainProcessor it needs to terminates.
     
    602604
    603605        // first task to abort ?
    604         if ( !kernel_abort_called ) {                   // not first task to abort ?
     606        if ( ! kernel_abort_called ) {                  // not first task to abort ?
    605607                kernel_abort_called = true;
    606608                unlock( kernel_abort_lock );
     
    617619        }
    618620
    619         return this_thread;
     621        return TL_GET( this_thread );
    620622}
    621623
     
    626628        __cfaabi_dbg_bits_write( abort_text, len );
    627629
    628         if ( thrd != this_coroutine ) {
    629                 len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", this_coroutine->name, this_coroutine );
     630        if ( get_coroutine(thrd) != TL_GET( this_coroutine ) ) {
     631                len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", TL_GET( this_coroutine )->name, TL_GET( this_coroutine ) );
    630632                __cfaabi_dbg_bits_write( abort_text, len );
    631633        }
     
    636638
    637639int kernel_abort_lastframe( void ) __attribute__ ((__nothrow__)) {
    638         return get_coroutine(this_thread) == get_coroutine(mainThread) ? 4 : 2;
     640        return get_coroutine(TL_GET( this_thread )) == get_coroutine(mainThread) ? 4 : 2;
    639641}
    640642
     
    666668        if ( count < 0 ) {
    667669                // queue current task
    668                 append( waiting, (thread_desc *)this_thread );
     670                append( waiting, (thread_desc *)TL_GET( this_thread ) );
    669671
    670672                // atomically release spin lock and block
  • src/libcfa/concurrency/kernel_private.h

    r2efe4b8 r1cdfa82  
    1010// Created On       : Mon Feb 13 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:58:09 2017
    13 // Update Count     : 2
     12// Last Modified On : Thu Mar 29 14:06:40 2018
     13// Update Count     : 3
    1414//
    1515
     
    6666extern event_kernel_t * event_kernel;
    6767
    68 extern thread_local coroutine_desc * volatile this_coroutine;
    69 extern thread_local thread_desc *    volatile this_thread;
    70 extern thread_local processor *      volatile this_processor;
     68//extern thread_local coroutine_desc * volatile this_coroutine;
     69//extern thread_local thread_desc *    volatile this_thread;
     70//extern thread_local processor *      volatile this_processor;
    7171
    7272// extern volatile thread_local bool preemption_in_progress;
  • src/libcfa/concurrency/monitor.c

    r2efe4b8 r1cdfa82  
    1010// Created On       : Thd Feb 23 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb 16 14:49:53 2018
    13 // Update Count     : 5
     12// Last Modified On : Fri Mar 30 14:30:26 2018
     13// Update Count     : 9
    1414//
    1515
     
    8585                // Lock the monitor spinlock
    8686                lock( this->lock __cfaabi_dbg_ctx2 );
    87                 thread_desc * thrd = this_thread;
     87                thread_desc * thrd = TL_GET( this_thread );
    8888
    8989                __cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
     
    134134                // Lock the monitor spinlock
    135135                lock( this->lock __cfaabi_dbg_ctx2 );
    136                 thread_desc * thrd = this_thread;
     136                thread_desc * thrd = TL_GET( this_thread );
    137137
    138138                __cfaabi_dbg_print_safe( "Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner);
     
    168168
    169169                        // Create the node specific to this wait operation
    170                         wait_ctx_primed( this_thread, 0 )
     170                        wait_ctx_primed( TL_GET( this_thread ), 0 )
    171171
    172172                        // Some one else has the monitor, wait for him to finish and then run
     
    179179                        __cfaabi_dbg_print_safe( "Kernel :  blocking \n" );
    180180
    181                         wait_ctx( this_thread, 0 )
     181                        wait_ctx( TL_GET( this_thread ), 0 )
    182182                        this->dtor_node = &waiter;
    183183
     
    199199                lock( this->lock __cfaabi_dbg_ctx2 );
    200200
    201                 __cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", this_thread, this, this->owner);
    202 
    203                 verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", this_thread, this->owner, this->recursion, this );
     201                __cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", TL_GET( this_thread ), this, this->owner);
     202
     203                verifyf( TL_GET( this_thread ) == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", TL_GET( this_thread ), this->owner, this->recursion, this );
    204204
    205205                // Leaving a recursion level, decrement the counter
     
    227227        void __leave_dtor_monitor_desc( monitor_desc * this ) {
    228228                __cfaabi_dbg_debug_do(
    229                         if( this_thread != this->owner ) {
    230                                 abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, this_thread, this->owner);
     229                        if( TL_GET( this_thread ) != this->owner ) {
     230                                abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, TL_GET( this_thread ), this->owner);
    231231                        }
    232232                        if( this->recursion != 1 ) {
     
    297297
    298298        // Save previous thread context
    299         this.prev = this_thread->monitors;
     299        this.prev = TL_GET( this_thread )->monitors;
    300300
    301301        // Update thread context (needed for conditions)
    302         (this_thread->monitors){m, count, func};
     302        (TL_GET( this_thread )->monitors){m, count, func};
    303303
    304304        // __cfaabi_dbg_print_safe( "MGUARD : enter %d\n", count);
     
    322322
    323323        // Restore thread context
    324         this_thread->monitors = this.prev;
     324        TL_GET( this_thread )->monitors = this.prev;
    325325}
    326326
     
    332332
    333333        // Save previous thread context
    334         this.prev = this_thread->monitors;
     334        this.prev = TL_GET( this_thread )->monitors;
    335335
    336336        // Update thread context (needed for conditions)
    337         (this_thread->monitors){m, 1, func};
     337        (TL_GET( this_thread )->monitors){m, 1, func};
    338338
    339339        __enter_monitor_dtor( this.m, func );
     
    346346
    347347        // Restore thread context
    348         this_thread->monitors = this.prev;
     348        TL_GET( this_thread )->monitors = this.prev;
    349349}
    350350
     
    386386
    387387        // Create the node specific to this wait operation
    388         wait_ctx( this_thread, user_info );
     388        wait_ctx( TL_GET( this_thread ), user_info );
    389389
    390390        // Append the current wait operation to the ones already queued on the condition
     
    425425        //Some more checking in debug
    426426        __cfaabi_dbg_debug_do(
    427                 thread_desc * this_thrd = this_thread;
     427                thread_desc * this_thrd = TL_GET( this_thread );
    428428                if ( this.monitor_count != this_thrd->monitors.size ) {
    429429                        abort( "Signal on condition %p made with different number of monitor(s), expected %zi got %zi", &this, this.monitor_count, this_thrd->monitors.size );
     
    473473
    474474        // Create the node specific to this wait operation
    475         wait_ctx_primed( this_thread, 0 )
     475        wait_ctx_primed( TL_GET( this_thread ), 0 )
    476476
    477477        //save contexts
     
    566566
    567567                                // Create the node specific to this wait operation
    568                                 wait_ctx_primed( this_thread, 0 );
     568                                wait_ctx_primed( TL_GET( this_thread ), 0 );
    569569
    570570                                // Save monitor states
     
    612612
    613613        // Create the node specific to this wait operation
    614         wait_ctx_primed( this_thread, 0 );
     614        wait_ctx_primed( TL_GET( this_thread ), 0 );
    615615
    616616        monitor_save;
     
    618618
    619619        for( __lock_size_t i = 0; i < count; i++) {
    620                 verify( monitors[i]->owner == this_thread );
     620                verify( monitors[i]->owner == TL_GET( this_thread ) );
    621621        }
    622622
     
    812812
    813813static inline void brand_condition( condition & this ) {
    814         thread_desc * thrd = this_thread;
     814        thread_desc * thrd = TL_GET( this_thread );
    815815        if( !this.monitors ) {
    816816                // __cfaabi_dbg_print_safe( "Branding\n" );
  • src/libcfa/concurrency/preemption.c

    r2efe4b8 r1cdfa82  
    1010// Created On       : Mon Jun 5 14:20:42 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb  9 16:38:13 2018
    13 // Update Count     : 14
     12// Last Modified On : Mon Apr  9 13:52:39 2018
     13// Update Count     : 36
    1414//
    1515
     
    2323}
    2424
    25 #include "bits/cfatime.h"
    2625#include "bits/signal.h"
    2726
    2827#if !defined(__CFA_DEFAULT_PREEMPTION__)
    29 #define __CFA_DEFAULT_PREEMPTION__ 10`cfa_ms
     28#define __CFA_DEFAULT_PREEMPTION__ 10`ms
    3029#endif
    3130
    32 __cfa_time_t default_preemption() __attribute__((weak)) {
     31Duration default_preemption() __attribute__((weak)) {
    3332        return __CFA_DEFAULT_PREEMPTION__;
    3433}
     
    7877
    7978// Get next expired node
    80 static inline alarm_node_t * get_expired( alarm_list_t * alarms, __cfa_time_t currtime ) {
     79static inline alarm_node_t * get_expired( alarm_list_t * alarms, Time currtime ) {
    8180        if( !alarms->head ) return NULL;                          // If no alarms return null
    8281        if( alarms->head->alarm >= currtime ) return NULL;        // If alarms head not expired return null
     
    8887        alarm_node_t * node = NULL;                     // Used in the while loop but cannot be declared in the while condition
    8988        alarm_list_t * alarms = &event_kernel->alarms;  // Local copy for ease of reading
    90         __cfa_time_t currtime = __kernel_get_time();    // Check current time once so we everything "happens at once"
     89        Time currtime = __kernel_get_time();                    // Check current time once so we everything "happens at once"
    9190
    9291        //Loop throught every thing expired
     
    102101
    103102                // Check if this is a periodic alarm
    104                 __cfa_time_t period = node->period;
     103                Duration period = node->period;
    105104                if( period > 0 ) {
    106105                        node->alarm = currtime + period;    // Alarm is periodic, add currtime to it (used cached current time)
     
    117116
    118117// Update the preemption of a processor and notify interested parties
    119 void update_preemption( processor * this, __cfa_time_t duration ) {
     118void update_preemption( processor * this, Duration duration ) {
    120119        alarm_node_t * alarm = this->preemption_alarm;
    121120
    122121        // Alarms need to be enabled
    123         if ( duration > 0 && !alarm->set ) {
     122        if ( duration > 0 && ! alarm->set ) {
    124123                alarm->alarm = __kernel_get_time() + duration;
    125124                alarm->period = duration;
    126125                register_self( alarm );
    127126        }
    128         // Zero duraction but alarm is set
     127        // Zero duration but alarm is set
    129128        else if ( duration == 0 && alarm->set ) {
    130129                unregister_self( alarm );
     
    150149        // Disable interrupts by incrementing the counter
    151150        void disable_interrupts() {
    152                 preemption_state.enabled = false;
    153                 __attribute__((unused)) unsigned short new_val = preemption_state.disable_count + 1;
    154                 preemption_state.disable_count = new_val;
     151                TL_GET( preemption_state ).enabled = false;
     152                __attribute__((unused)) unsigned short new_val = TL_GET( preemption_state ).disable_count + 1;
     153                TL_GET( preemption_state ).disable_count = new_val;
    155154                verify( new_val < 65_000u );              // If this triggers someone is disabling interrupts without enabling them
    156155        }
     
    159158        // If counter reaches 0, execute any pending CtxSwitch
    160159        void enable_interrupts( __cfaabi_dbg_ctx_param ) {
    161                 processor   * proc = this_processor;      // Cache the processor now since interrupts can start happening after the atomic add
    162                 thread_desc * thrd = this_thread;         // Cache the thread now since interrupts can start happening after the atomic add
    163 
    164                 unsigned short prev = preemption_state.disable_count;
    165                 preemption_state.disable_count -= 1;
     160                processor   * proc = TL_GET( this_processor ); // Cache the processor now since interrupts can start happening after the atomic add
     161                thread_desc * thrd = TL_GET( this_thread );       // Cache the thread now since interrupts can start happening after the atomic add
     162
     163                unsigned short prev = TL_GET( preemption_state ).disable_count;
     164                TL_GET( preemption_state ).disable_count -= 1;
    166165                verify( prev != 0u );                     // If this triggers someone is enabled already enabled interruptsverify( prev != 0u );
    167166
    168167                // Check if we need to prempt the thread because an interrupt was missed
    169168                if( prev == 1 ) {
    170                         preemption_state.enabled = true;
     169                        TL_GET( preemption_state ).enabled = true;
    171170                        if( proc->pending_preemption ) {
    172171                                proc->pending_preemption = false;
     
    182181        // Don't execute any pending CtxSwitch even if counter reaches 0
    183182        void enable_interrupts_noPoll() {
    184                 unsigned short prev = preemption_state.disable_count;
    185                 preemption_state.disable_count -= 1;
     183                unsigned short prev = TL_GET( preemption_state ).disable_count;
     184                TL_GET( preemption_state ).disable_count -= 1;
    186185                verifyf( prev != 0u, "Incremented from %u\n", prev );                     // If this triggers someone is enabled already enabled interrupts
    187186                if( prev == 1 ) {
    188                         preemption_state.enabled = true;
     187                        TL_GET( preemption_state ).enabled = true;
    189188                }
    190189        }
     
    236235// If false : preemption is unsafe and marked as pending
    237236static inline bool preemption_ready() {
    238         bool ready = preemption_state.enabled && !preemption_state.in_progress; // Check if preemption is safe
    239         this_processor->pending_preemption = !ready;                        // Adjust the pending flag accordingly
     237        bool ready = TL_GET( preemption_state ).enabled && !TL_GET( preemption_state ).in_progress; // Check if preemption is safe
     238        TL_GET( this_processor )->pending_preemption = !ready;                  // Adjust the pending flag accordingly
    240239        return ready;
    241240}
     
    251250
    252251        // Start with preemption disabled until ready
    253         preemption_state.enabled = false;
    254         preemption_state.disable_count = 1;
     252        TL_GET( preemption_state ).enabled = false;
     253        TL_GET( preemption_state ).disable_count = 1;
    255254
    256255        // Initialize the event kernel
     
    291290// Used by thread to control when they want to receive preemption signals
    292291void ?{}( preemption_scope & this, processor * proc ) {
    293         (this.alarm){ proc, 0`cfa_s, 0`cfa_s };
     292        (this.alarm){ proc, (Time){ 0 }, 0`s };
    294293        this.proc = proc;
    295294        this.proc->preemption_alarm = &this.alarm;
     
    301300        disable_interrupts();
    302301
    303         update_preemption( this.proc, 0`cfa_s );
     302        update_preemption( this.proc, 0`s );
    304303}
    305304
     
    317316        // before the kernel thread has even started running. When that happens an iterrupt
    318317        // we a null 'this_processor' will be caught, just ignore it.
    319         if(!this_processor) return;
     318        if(!TL_GET( this_processor )) return;
    320319
    321320        choose(sfp->si_value.sival_int) {
    322321                case PREEMPT_NORMAL   : ;// Normal case, nothing to do here
    323                 case PREEMPT_TERMINATE: verify(this_processor->do_terminate);
     322                case PREEMPT_TERMINATE: verify(TL_GET( this_processor )->do_terminate);
    324323                default:
    325324                        abort( "internal error, signal value is %d", sfp->si_value.sival_int );
     
    331330        __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", this_processor, this_thread);
    332331
    333         preemption_state.in_progress = true;                      // Sync flag : prevent recursive calls to the signal handler
     332        TL_GET( preemption_state ).in_progress = true;  // Sync flag : prevent recursive calls to the signal handler
    334333        signal_unblock( SIGUSR1 );                          // We are about to CtxSwitch out of the signal handler, let other handlers in
    335         preemption_state.in_progress = false;                    // Clear the in progress flag
     334        TL_GET( preemption_state ).in_progress = false; // Clear the in progress flag
    336335
    337336        // Preemption can occur here
    338337
    339         BlockInternal( (thread_desc*)this_thread );        // Do the actual CtxSwitch
     338        BlockInternal( (thread_desc*)TL_GET( this_thread ) ); // Do the actual CtxSwitch
    340339}
    341340
  • src/libcfa/concurrency/preemption.h

    r2efe4b8 r1cdfa82  
    1010// Created On       : Mon Jun 5 14:20:42 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:34:25 2017
    13 // Update Count     : 1
     12// Last Modified On : Fri Mar 23 17:18:53 2018
     13// Update Count     : 2
    1414//
    1515
     
    2121void kernel_start_preemption();
    2222void kernel_stop_preemption();
    23 void update_preemption( processor * this, __cfa_time_t duration );
     23void update_preemption( processor * this, Duration duration );
    2424void tick_preemption();
    2525
  • src/libcfa/concurrency/thread

    r2efe4b8 r1cdfa82  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:59:40 2017
    13 // Update Count     : 3
     12// Last Modified On : Thu Mar 29 14:07:11 2018
     13// Update Count     : 4
    1414//
    1515
     
    5252}
    5353
    54 extern thread_local thread_desc * volatile this_thread;
     54//extern thread_local thread_desc * volatile this_thread;
    5555
    5656forall( dtype T | is_thread(T) )
  • src/libcfa/concurrency/thread.c

    r2efe4b8 r1cdfa82  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:34:46 2017
    13 // Update Count     : 1
     12// Last Modified On : Fri Mar 30 17:19:52 2018
     13// Update Count     : 8
    1414//
    1515
     
    2626}
    2727
    28 extern volatile thread_local processor * this_processor;
     28//extern volatile thread_local processor * this_processor;
    2929
    3030//-----------------------------------------------------------------------------
     
    7575        coroutine_desc* thrd_c = get_coroutine(this);
    7676        thread_desc   * thrd_h = get_thread   (this);
    77         thrd_c->last = this_coroutine;
     77        thrd_c->last = TL_GET( this_coroutine );
    7878
    7979        // __cfaabi_dbg_print_safe("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h);
     
    8181        disable_interrupts();
    8282        create_stack(&thrd_c->stack, thrd_c->stack.size);
    83         this_coroutine = thrd_c;
     83        TL_SET( this_coroutine, thrd_c );
    8484        CtxStart(&this, CtxInvokeThread);
    8585        assert( thrd_c->last->stack.context );
     
    9292extern "C" {
    9393        void __finish_creation(void) {
    94                 coroutine_desc* thrd_c = this_coroutine;
     94                coroutine_desc* thrd_c = TL_GET( this_coroutine );
    9595                ThreadCtxSwitch( thrd_c, thrd_c->last );
    9696        }
     
    9898
    9999void yield( void ) {
    100         verify( preemption_state.enabled );
    101         BlockInternal( this_thread );
    102         verify( preemption_state.enabled );
     100        verify( TL_GET( preemption_state ).enabled );
     101        BlockInternal( TL_GET( this_thread ) );
     102        verify( TL_GET( preemption_state ).enabled );
    103103}
    104104
     
    116116        // set new coroutine that the processor is executing
    117117        // and context switch to it
    118         this_coroutine = dst;
     118        TL_SET( this_coroutine, dst );
    119119        assert( src->stack.context );
    120120        CtxSwitch( src->stack.context, dst->stack.context );
    121         this_coroutine = src;
     121        TL_SET( this_coroutine, src );
    122122
    123123        // set state of new coroutine to active
  • src/libcfa/iostream

    r2efe4b8 r1cdfa82  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 25 13:08:39 2018
    13 // Update Count     : 149
     12// Last Modified On : Thu Apr 12 14:34:37 2018
     13// Update Count     : 150
    1414//
    1515
     
    159159forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Istream_cstrC );
    160160
     161
     162#include <time_t.h>                                                                             // Duration (constructors) / Time (constructors)
     163
     164forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur );
     165forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );
     166
     167
    161168// Local Variables: //
    162169// mode: c //
  • src/libcfa/stdlib.c

    r2efe4b8 r1cdfa82  
    9999        char * eeptr;
    100100        re = strtof( sptr, &eeptr );
    101         if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }
     101        if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }
    102102        im = strtof( eeptr, &eeptr );
    103         if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }
     103        if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }
    104104        if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }
    105105        return re + im * _Complex_I;
     
    110110        char * eeptr;
    111111        re = strtod( sptr, &eeptr );
    112         if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }
     112        if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }
    113113        im = strtod( eeptr, &eeptr );
    114         if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }
     114        if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }
    115115        if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }
    116116        return re + im * _Complex_I;
     
    121121        char * eeptr;
    122122        re = strtold( sptr, &eeptr );
    123         if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }
     123        if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }
    124124        im = strtold( eeptr, &eeptr );
    125         if ( sptr == *eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }
     125        if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }
    126126        if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }
    127127        return re + im * _Complex_I;
  • src/tests/.expect/attributes.x64.txt

    r2efe4b8 r1cdfa82  
    33    L: __attribute__ ((unused)) ((void)1);
    44}
    5 __attribute__ ((unused)) struct __anonymous0 {
     5struct __attribute__ ((unused)) __anonymous0 {
    66};
    77static inline void ___constructor__F_R13s__anonymous0_autogen___1(struct __anonymous0 *___dst__R13s__anonymous0_1);
     
    2020    return ___ret__13s__anonymous0_1;
    2121}
    22 __attribute__ ((unused)) struct Agn1;
    23 __attribute__ ((unused)) struct Agn2 {
     22struct __attribute__ ((unused)) Agn1;
     23struct __attribute__ ((unused)) Agn2 {
    2424};
    2525static inline void ___constructor__F_R5sAgn2_autogen___1(struct Agn2 *___dst__R5sAgn2_1);
     
    4545    __E2__C5eAgn3_1,
    4646};
    47 __attribute__ ((unused)) struct __anonymous2;
    48 __attribute__ ((unused)) struct __anonymous3;
     47struct __attribute__ ((unused)) __anonymous2;
     48struct __attribute__ ((unused)) __anonymous3;
    4949struct Fdl {
    5050    __attribute__ ((unused)) signed int __f1__i_1;
     
    314314    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[10]));
    315315    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ()));
    316     __attribute__ ((unused)) struct __anonymous4 {
     316    struct __attribute__ ((unused)) __anonymous4 {
    317317        signed int __i__i_2;
    318318    };
     
    381381        signed int _index0 = 0;
    382382        for (;(_index0<10);((void)(++_index0))) {
    383             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index0)])))) /* ?{} */);
     383            ((void)((*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index0)]) /* ?{} */);
    384384        }
    385385
     
    394394        signed int _index1 = 0;
    395395        for (;(_index1<10);((void)(++_index1))) {
    396             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index1)])))=___src__4sVad_1.__anonymous_object34[((signed long int )_index1)]) /* ?{} */);
     396            ((void)((*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index1)]=___src__4sVad_1.__anonymous_object34[((signed long int )_index1)]) /* ?{} */);
    397397        }
    398398
     
    406406        signed int _index2 = (10-1);
    407407        for (;(_index2>=0);((void)(--_index2))) {
    408             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index2)])))) /* ^?{} */);
     408            ((void)((*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index2)]) /* ^?{} */);
    409409        }
    410410
     
    436436        signed int _index4 = 0;
    437437        for (;(_index4<10);((void)(++_index4))) {
    438             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index4)])))) /* ?{} */);
     438            ((void)((*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index4)]) /* ?{} */);
    439439        }
    440440
     
    449449        signed int _index5 = 0;
    450450        for (;(_index5<10);((void)(++_index5))) {
    451             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index5)])))) /* ?{} */);
     451            ((void)((*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index5)]) /* ?{} */);
    452452        }
    453453
     
    462462        signed int _index6 = 0;
    463463        for (;(_index6<10);((void)(++_index6))) {
    464             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index6)])))=__anonymous_object51[((signed long int )_index6)]) /* ?{} */);
     464            ((void)((*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index6)]=__anonymous_object51[((signed long int )_index6)]) /* ?{} */);
    465465        }
    466466
     
    475475        signed int _index7 = 0;
    476476        for (;(_index7<10);((void)(++_index7))) {
    477             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index7)])))=__anonymous_object54[((signed long int )_index7)]) /* ?{} */);
     477            ((void)((*___dst__R4sVad_1).__anonymous_object34[((signed long int )_index7)]=__anonymous_object54[((signed long int )_index7)]) /* ?{} */);
    478478        }
    479479
  • src/tests/.expect/attributes.x86.txt

    r2efe4b8 r1cdfa82  
    33    L: __attribute__ ((unused)) ((void)1);
    44}
    5 __attribute__ ((unused)) struct __anonymous0 {
     5struct __attribute__ ((unused)) __anonymous0 {
    66};
    77static inline void ___constructor__F_R13s__anonymous0_autogen___1(struct __anonymous0 *___dst__R13s__anonymous0_1);
     
    2020    return ___ret__13s__anonymous0_1;
    2121}
    22 __attribute__ ((unused)) struct Agn1;
    23 __attribute__ ((unused)) struct Agn2 {
     22struct __attribute__ ((unused)) Agn1;
     23struct __attribute__ ((unused)) Agn2 {
    2424};
    2525static inline void ___constructor__F_R5sAgn2_autogen___1(struct Agn2 *___dst__R5sAgn2_1);
     
    4545    __E2__C5eAgn3_1,
    4646};
    47 __attribute__ ((unused)) struct __anonymous2;
    48 __attribute__ ((unused)) struct __anonymous3;
     47struct __attribute__ ((unused)) __anonymous2;
     48struct __attribute__ ((unused)) __anonymous3;
    4949struct Fdl {
    5050    __attribute__ ((unused)) signed int __f1__i_1;
     
    314314    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[10]));
    315315    ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ()));
    316     __attribute__ ((unused)) struct __anonymous4 {
     316    struct __attribute__ ((unused)) __anonymous4 {
    317317        signed int __i__i_2;
    318318    };
     
    381381        signed int _index0 = 0;
    382382        for (;(_index0<10);((void)(++_index0))) {
    383             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[_index0])))) /* ?{} */);
     383            ((void)((*___dst__R4sVad_1).__anonymous_object34[_index0]) /* ?{} */);
    384384        }
    385385
     
    394394        signed int _index1 = 0;
    395395        for (;(_index1<10);((void)(++_index1))) {
    396             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[_index1])))=___src__4sVad_1.__anonymous_object34[_index1]) /* ?{} */);
     396            ((void)((*___dst__R4sVad_1).__anonymous_object34[_index1]=___src__4sVad_1.__anonymous_object34[_index1]) /* ?{} */);
    397397        }
    398398
     
    406406        signed int _index2 = (10-1);
    407407        for (;(_index2>=0);((void)(--_index2))) {
    408             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[_index2])))) /* ^?{} */);
     408            ((void)((*___dst__R4sVad_1).__anonymous_object34[_index2]) /* ^?{} */);
    409409        }
    410410
     
    436436        signed int _index4 = 0;
    437437        for (;(_index4<10);((void)(++_index4))) {
    438             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[_index4])))) /* ?{} */);
     438            ((void)((*___dst__R4sVad_1).__anonymous_object34[_index4]) /* ?{} */);
    439439        }
    440440
     
    449449        signed int _index5 = 0;
    450450        for (;(_index5<10);((void)(++_index5))) {
    451             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[_index5])))) /* ?{} */);
     451            ((void)((*___dst__R4sVad_1).__anonymous_object34[_index5]) /* ?{} */);
    452452        }
    453453
     
    462462        signed int _index6 = 0;
    463463        for (;(_index6<10);((void)(++_index6))) {
    464             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[_index6])))=__anonymous_object51[_index6]) /* ?{} */);
     464            ((void)((*___dst__R4sVad_1).__anonymous_object34[_index6]=__anonymous_object51[_index6]) /* ?{} */);
    465465        }
    466466
     
    475475        signed int _index7 = 0;
    476476        for (;(_index7<10);((void)(++_index7))) {
    477             ((void)((*((signed int *)(&(*___dst__R4sVad_1).__anonymous_object34[_index7])))=__anonymous_object54[_index7]) /* ?{} */);
     477            ((void)((*___dst__R4sVad_1).__anonymous_object34[_index7]=__anonymous_object54[_index7]) /* ?{} */);
    478478        }
    479479
  • src/tests/.expect/extension.x64.txt

    r2efe4b8 r1cdfa82  
    193193    }
    194194    ((void)__extension__ sizeof(3));
    195     ((void)__extension__ (((signed int )(3!=((signed int )0))) || ((signed int )(4!=((signed int )0)))));
     195    ((void)__extension__ ((3!=((signed int )0)) || (4!=((signed int )0))));
    196196    ((void)__extension__ __alignof__(__extension__ __a__i_2));
    197     ((void)(((signed int )(__extension__ __a__i_2!=((signed int )0))) || ((signed int )((((signed int )(__extension__ __b__i_2!=((signed int )0))) && ((signed int )(__extension__ __c__i_2!=((signed int )0))))!=((signed int )0)))));
    198     ((void)(((signed int )((__extension__ __a__i_2>__extension__ __b__i_2)!=((signed int )0))) ? __extension__ __c__i_2 : __extension__ __c__i_2));
     197    ((void)((__extension__ __a__i_2!=((signed int )0)) || (((__extension__ __b__i_2!=((signed int )0)) && (__extension__ __c__i_2!=((signed int )0)))!=((signed int )0))));
     198    ((void)(((__extension__ __a__i_2>__extension__ __b__i_2)!=((signed int )0)) ? __extension__ __c__i_2 : __extension__ __c__i_2));
    199199    ((void)(__extension__ __a__i_2=__extension__ (__extension__ __b__i_2+__extension__ __c__i_2)));
    200200    ((void)(((void)(((void)__extension__ __a__i_2) , __extension__ __b__i_2)) , __extension__ __c__i_2));
  • src/tests/.expect/extension.x86.txt

    r2efe4b8 r1cdfa82  
    193193    }
    194194    ((void)__extension__ sizeof(3));
    195     ((void)__extension__ (((signed int )(3!=((signed int )0))) || ((signed int )(4!=((signed int )0)))));
     195    ((void)__extension__ ((3!=((signed int )0)) || (4!=((signed int )0))));
    196196    ((void)__extension__ __alignof__(__extension__ __a__i_2));
    197     ((void)(((signed int )(__extension__ __a__i_2!=((signed int )0))) || ((signed int )((((signed int )(__extension__ __b__i_2!=((signed int )0))) && ((signed int )(__extension__ __c__i_2!=((signed int )0))))!=((signed int )0)))));
    198     ((void)(((signed int )((__extension__ __a__i_2>__extension__ __b__i_2)!=((signed int )0))) ? __extension__ __c__i_2 : __extension__ __c__i_2));
     197    ((void)((__extension__ __a__i_2!=((signed int )0)) || (((__extension__ __b__i_2!=((signed int )0)) && (__extension__ __c__i_2!=((signed int )0)))!=((signed int )0))));
     198    ((void)(((__extension__ __a__i_2>__extension__ __b__i_2)!=((signed int )0)) ? __extension__ __c__i_2 : __extension__ __c__i_2));
    199199    ((void)(__extension__ __a__i_2=__extension__ (__extension__ __b__i_2+__extension__ __c__i_2)));
    200200    ((void)(((void)(((void)__extension__ __a__i_2) , __extension__ __b__i_2)) , __extension__ __c__i_2));
  • src/tests/.expect/literals.x64.txt

    r2efe4b8 r1cdfa82  
    122122struct _Istream_cstrC __cstr__F15s_Istream_cstrC_Pci__1(char *__anonymous_object1340, signed int __size__i_1);
    123123void *___operator_bitor__A0_1_0_0___fail__PFi_Rd0___eof__PFi_Rd0___open__PF_Rd0PCc___close__PF_Rd0___read__PFRd0_Rd0PcUl___ungetc__PFRd0_Rd0c___fmt__PFi_Rd0PCc__FRd0_Rd015s_Istream_cstrC__1(__attribute__ ((unused)) signed int (*__fail__PFi_R7tistype__1)(void *__anonymous_object1341), __attribute__ ((unused)) signed int (*__eof__PFi_R7tistype__1)(void *__anonymous_object1342), __attribute__ ((unused)) void (*__open__PF_R7tistypePCc__1)(void *__is__R7tistype_1, const char *__name__PCc_1), __attribute__ ((unused)) void (*__close__PF_R7tistype__1)(void *__is__R7tistype_1), __attribute__ ((unused)) void *(*__read__PFR7tistype_R7tistypePcUl__1)(void *__anonymous_object1343, char *__anonymous_object1344, unsigned long int __anonymous_object1345), __attribute__ ((unused)) void *(*__ungetc__PFR7tistype_R7tistypec__1)(void *__anonymous_object1346, char __anonymous_object1347), __attribute__ ((unused)) signed int (*__fmt__PFi_R7tistypePCc__1)(void *__anonymous_object1348, const char *__fmt__PCc_1, ...), void *__anonymous_object1349, struct _Istream_cstrC __anonymous_object1350);
     124struct Duration {
     125    signed long int __tv__l_1;
     126};
     127static inline void ___constructor__F_R9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1);
     128static inline void ___constructor__F_R9sDuration9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1, struct Duration ___src__9sDuration_1);
     129static inline void ___destructor__F_R9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1);
     130static inline struct Duration ___operator_assign__F9sDuration_R9sDuration9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1, struct Duration ___src__9sDuration_1);
     131static inline void ___constructor__F_R9sDurationl_autogen___1(struct Duration *___dst__R9sDuration_1, signed long int __tv__l_1);
     132static inline void ___constructor__F_R9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1){
     133    ((void)((*___dst__R9sDuration_1).__tv__l_1) /* ?{} */);
     134}
     135static inline void ___constructor__F_R9sDuration9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1, struct Duration ___src__9sDuration_1){
     136    ((void)((*___dst__R9sDuration_1).__tv__l_1=___src__9sDuration_1.__tv__l_1) /* ?{} */);
     137}
     138static inline void ___destructor__F_R9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1){
     139    ((void)((*___dst__R9sDuration_1).__tv__l_1) /* ^?{} */);
     140}
     141static inline struct Duration ___operator_assign__F9sDuration_R9sDuration9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1, struct Duration ___src__9sDuration_1){
     142    struct Duration ___ret__9sDuration_1;
     143    ((void)((*___dst__R9sDuration_1).__tv__l_1=___src__9sDuration_1.__tv__l_1));
     144    ((void)___constructor__F_R9sDuration9sDuration_autogen___1((&___ret__9sDuration_1), (*___dst__R9sDuration_1)));
     145    return ___ret__9sDuration_1;
     146}
     147static inline void ___constructor__F_R9sDurationl_autogen___1(struct Duration *___dst__R9sDuration_1, signed long int __tv__l_1){
     148    ((void)((*___dst__R9sDuration_1).__tv__l_1=__tv__l_1) /* ?{} */);
     149}
     150static inline void ___constructor__F_R9sDuration__1(struct Duration *__dur__R9sDuration_1){
     151    ((void)((*__dur__R9sDuration_1).__tv__l_1) /* ?{} */);
     152    ((void)((*__dur__R9sDuration_1).__tv__l_1=((signed long int )0)));
     153}
     154static inline void ___constructor__F_R9sDurationZ__1(struct Duration *__dur__R9sDuration_1, long int __anonymous_object1351){
     155    ((void)((*__dur__R9sDuration_1).__tv__l_1) /* ?{} */);
     156    ((void)((*__dur__R9sDuration_1).__tv__l_1=((signed long int )0)));
     157}
     158struct Time {
     159    unsigned long int __tv__Ul_1;
     160};
     161static inline void ___constructor__F_R5sTime_autogen___1(struct Time *___dst__R5sTime_1);
     162static inline void ___constructor__F_R5sTime5sTime_autogen___1(struct Time *___dst__R5sTime_1, struct Time ___src__5sTime_1);
     163static inline void ___destructor__F_R5sTime_autogen___1(struct Time *___dst__R5sTime_1);
     164static inline struct Time ___operator_assign__F5sTime_R5sTime5sTime_autogen___1(struct Time *___dst__R5sTime_1, struct Time ___src__5sTime_1);
     165static inline void ___constructor__F_R5sTimeUl_autogen___1(struct Time *___dst__R5sTime_1, unsigned long int __tv__Ul_1);
     166static inline void ___constructor__F_R5sTime_autogen___1(struct Time *___dst__R5sTime_1){
     167    ((void)((*___dst__R5sTime_1).__tv__Ul_1) /* ?{} */);
     168}
     169static inline void ___constructor__F_R5sTime5sTime_autogen___1(struct Time *___dst__R5sTime_1, struct Time ___src__5sTime_1){
     170    ((void)((*___dst__R5sTime_1).__tv__Ul_1=___src__5sTime_1.__tv__Ul_1) /* ?{} */);
     171}
     172static inline void ___destructor__F_R5sTime_autogen___1(struct Time *___dst__R5sTime_1){
     173    ((void)((*___dst__R5sTime_1).__tv__Ul_1) /* ^?{} */);
     174}
     175static inline struct Time ___operator_assign__F5sTime_R5sTime5sTime_autogen___1(struct Time *___dst__R5sTime_1, struct Time ___src__5sTime_1){
     176    struct Time ___ret__5sTime_1;
     177    ((void)((*___dst__R5sTime_1).__tv__Ul_1=___src__5sTime_1.__tv__Ul_1));
     178    ((void)___constructor__F_R5sTime5sTime_autogen___1((&___ret__5sTime_1), (*___dst__R5sTime_1)));
     179    return ___ret__5sTime_1;
     180}
     181static inline void ___constructor__F_R5sTimeUl_autogen___1(struct Time *___dst__R5sTime_1, unsigned long int __tv__Ul_1){
     182    ((void)((*___dst__R5sTime_1).__tv__Ul_1=__tv__Ul_1) /* ?{} */);
     183}
     184static inline void ___constructor__F_R5sTime__1(struct Time *__time__R5sTime_1){
     185    ((void)((*__time__R5sTime_1).__tv__Ul_1) /* ?{} */);
     186    ((void)((*__time__R5sTime_1).__tv__Ul_1=((unsigned long int )0)));
     187}
     188static inline void ___constructor__F_R5sTimeZ__1(struct Time *__time__R5sTime_1, long int __anonymous_object1352){
     189    ((void)((*__time__R5sTime_1).__tv__Ul_1) /* ?{} */);
     190    ((void)((*__time__R5sTime_1).__tv__Ul_1=((unsigned long int )0)));
     191}
     192void *___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd09sDuration__1(__attribute__ ((unused)) _Bool (*__sepPrt__PFb_R7tostype__1)(void *__anonymous_object1353), __attribute__ ((unused)) void (*__sepReset__PF_R7tostype__1)(void *__anonymous_object1354), __attribute__ ((unused)) void (*__sepReset__PF_R7tostypeb__1)(void *__anonymous_object1355, _Bool __anonymous_object1356), __attribute__ ((unused)) const char *(*__sepGetCur__PFPCc_R7tostype__1)(void *__anonymous_object1357), __attribute__ ((unused)) void (*__sepSetCur__PF_R7tostypePCc__1)(void *__anonymous_object1358, const char *__anonymous_object1359), __attribute__ ((unused)) _Bool (*__getNL__PFb_R7tostype__1)(void *__anonymous_object1360), __attribute__ ((unused)) void (*__setNL__PF_R7tostypeb__1)(void *__anonymous_object1361, _Bool __anonymous_object1362), __attribute__ ((unused)) void (*__sepOn__PF_R7tostype__1)(void *__anonymous_object1363), __attribute__ ((unused)) void (*__sepOff__PF_R7tostype__1)(void *__anonymous_object1364), __attribute__ ((unused)) _Bool (*__sepDisable__PFb_R7tostype__1)(void *__anonymous_object1365), __attribute__ ((unused)) _Bool (*__sepEnable__PFb_R7tostype__1)(void *__anonymous_object1366), __attribute__ ((unused)) const char *(*__sepGet__PFPCc_R7tostype__1)(void *__anonymous_object1367), __attribute__ ((unused)) void (*__sepSet__PF_R7tostypePCc__1)(void *__anonymous_object1368, const char *__anonymous_object1369), __attribute__ ((unused)) const char *(*__sepGetTuple__PFPCc_R7tostype__1)(void *__anonymous_object1370), __attribute__ ((unused)) void (*__sepSetTuple__PF_R7tostypePCc__1)(void *__anonymous_object1371, const char *__anonymous_object1372), __attribute__ ((unused)) signed int (*__fail__PFi_R7tostype__1)(void *__anonymous_object1373), __attribute__ ((unused)) signed int (*__flush__PFi_R7tostype__1)(void *__anonymous_object1374), __attribute__ ((unused)) void (*__open__PF_R7tostypePCcPCc__1)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1), __attribute__ ((unused)) void (*__close__PF_R7tostype__1)(void *__os__R7tostype_1), __attribute__ ((unused)) void *(*__write__PFR7tostype_R7tostypePCcUl__1)(void *__anonymous_object1375, const char *__anonymous_object1376, unsigned long int __anonymous_object1377), __attribute__ ((unused)) signed int (*__fmt__PFi_R7tostypePCc__1)(void *__anonymous_object1378, const char *__fmt__PCc_1, ...), void *__os__R7tostype_1, struct Duration __dur__9sDuration_1);
     193void *___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd05sTime__1(__attribute__ ((unused)) _Bool (*__sepPrt__PFb_R7tostype__1)(void *__anonymous_object1379), __attribute__ ((unused)) void (*__sepReset__PF_R7tostype__1)(void *__anonymous_object1380), __attribute__ ((unused)) void (*__sepReset__PF_R7tostypeb__1)(void *__anonymous_object1381, _Bool __anonymous_object1382), __attribute__ ((unused)) const char *(*__sepGetCur__PFPCc_R7tostype__1)(void *__anonymous_object1383), __attribute__ ((unused)) void (*__sepSetCur__PF_R7tostypePCc__1)(void *__anonymous_object1384, const char *__anonymous_object1385), __attribute__ ((unused)) _Bool (*__getNL__PFb_R7tostype__1)(void *__anonymous_object1386), __attribute__ ((unused)) void (*__setNL__PF_R7tostypeb__1)(void *__anonymous_object1387, _Bool __anonymous_object1388), __attribute__ ((unused)) void (*__sepOn__PF_R7tostype__1)(void *__anonymous_object1389), __attribute__ ((unused)) void (*__sepOff__PF_R7tostype__1)(void *__anonymous_object1390), __attribute__ ((unused)) _Bool (*__sepDisable__PFb_R7tostype__1)(void *__anonymous_object1391), __attribute__ ((unused)) _Bool (*__sepEnable__PFb_R7tostype__1)(void *__anonymous_object1392), __attribute__ ((unused)) const char *(*__sepGet__PFPCc_R7tostype__1)(void *__anonymous_object1393), __attribute__ ((unused)) void (*__sepSet__PF_R7tostypePCc__1)(void *__anonymous_object1394, const char *__anonymous_object1395), __attribute__ ((unused)) const char *(*__sepGetTuple__PFPCc_R7tostype__1)(void *__anonymous_object1396), __attribute__ ((unused)) void (*__sepSetTuple__PF_R7tostypePCc__1)(void *__anonymous_object1397, const char *__anonymous_object1398), __attribute__ ((unused)) signed int (*__fail__PFi_R7tostype__1)(void *__anonymous_object1399), __attribute__ ((unused)) signed int (*__flush__PFi_R7tostype__1)(void *__anonymous_object1400), __attribute__ ((unused)) void (*__open__PF_R7tostypePCcPCc__1)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1), __attribute__ ((unused)) void (*__close__PF_R7tostype__1)(void *__os__R7tostype_1), __attribute__ ((unused)) void *(*__write__PFR7tostype_R7tostypePCcUl__1)(void *__anonymous_object1401, const char *__anonymous_object1402, unsigned long int __anonymous_object1403), __attribute__ ((unused)) signed int (*__fmt__PFi_R7tostypePCc__1)(void *__anonymous_object1404, const char *__fmt__PCc_1, ...), void *__os__R7tostype_1, struct Time __time__5sTime_1);
    124194enum __anonymous0 {
    125195    __sepSize__C13e__anonymous0_1 = 16,
     
    154224        signed int _index0 = 0;
    155225        for (;(_index0<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index0))) {
    156             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index0)])))) /* ?{} */);
     226            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index0)]) /* ?{} */);
    157227        }
    158228
     
    162232        signed int _index1 = 0;
    163233        for (;(_index1<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index1))) {
    164             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index1)])))) /* ?{} */);
     234            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index1)]) /* ?{} */);
    165235        }
    166236
     
    177247        signed int _index2 = 0;
    178248        for (;(_index2<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index2))) {
    179             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index2)])))=___src__9sofstream_1.__separator__A0c_1[((signed long int )_index2)]) /* ?{} */);
     249            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index2)]=___src__9sofstream_1.__separator__A0c_1[((signed long int )_index2)]) /* ?{} */);
    180250        }
    181251
     
    185255        signed int _index3 = 0;
    186256        for (;(_index3<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index3))) {
    187             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index3)])))=___src__9sofstream_1.__tupleSeparator__A0c_1[((signed long int )_index3)]) /* ?{} */);
     257            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index3)]=___src__9sofstream_1.__tupleSeparator__A0c_1[((signed long int )_index3)]) /* ?{} */);
    188258        }
    189259
     
    195265        signed int _index4 = (((signed int )__sepSize__C13e__anonymous0_1)-1);
    196266        for (;(_index4>=0);((void)(--_index4))) {
    197             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index4)])))) /* ^?{} */);
     267            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index4)]) /* ^?{} */);
    198268        }
    199269
     
    203273        signed int _index5 = (((signed int )__sepSize__C13e__anonymous0_1)-1);
    204274        for (;(_index5>=0);((void)(--_index5))) {
    205             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index5)])))) /* ^?{} */);
     275            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index5)]) /* ^?{} */);
    206276        }
    207277
     
    249319        signed int _index8 = 0;
    250320        for (;(_index8<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index8))) {
    251             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index8)])))) /* ?{} */);
     321            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index8)]) /* ?{} */);
    252322        }
    253323
     
    257327        signed int _index9 = 0;
    258328        for (;(_index9<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index9))) {
    259             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index9)])))) /* ?{} */);
     329            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index9)]) /* ?{} */);
    260330        }
    261331
     
    272342        signed int _index10 = 0;
    273343        for (;(_index10<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index10))) {
    274             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index10)])))) /* ?{} */);
     344            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index10)]) /* ?{} */);
    275345        }
    276346
     
    280350        signed int _index11 = 0;
    281351        for (;(_index11<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index11))) {
    282             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index11)])))) /* ?{} */);
     352            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index11)]) /* ?{} */);
    283353        }
    284354
     
    295365        signed int _index12 = 0;
    296366        for (;(_index12<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index12))) {
    297             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index12)])))) /* ?{} */);
     367            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index12)]) /* ?{} */);
    298368        }
    299369
     
    303373        signed int _index13 = 0;
    304374        for (;(_index13<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index13))) {
    305             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index13)])))) /* ?{} */);
     375            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index13)]) /* ?{} */);
    306376        }
    307377
     
    318388        signed int _index14 = 0;
    319389        for (;(_index14<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index14))) {
    320             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index14)])))) /* ?{} */);
     390            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index14)]) /* ?{} */);
    321391        }
    322392
     
    326396        signed int _index15 = 0;
    327397        for (;(_index15<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index15))) {
    328             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index15)])))) /* ?{} */);
     398            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index15)]) /* ?{} */);
    329399        }
    330400
     
    341411        signed int _index16 = 0;
    342412        for (;(_index16<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index16))) {
    343             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index16)])))) /* ?{} */);
     413            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index16)]) /* ?{} */);
    344414        }
    345415
     
    349419        signed int _index17 = 0;
    350420        for (;(_index17<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index17))) {
    351             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index17)])))) /* ?{} */);
     421            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index17)]) /* ?{} */);
    352422        }
    353423
     
    364434        signed int _index18 = 0;
    365435        for (;(_index18<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index18))) {
    366             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index18)])))=__separator__A0c_1[((signed long int )_index18)]) /* ?{} */);
     436            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index18)]=__separator__A0c_1[((signed long int )_index18)]) /* ?{} */);
    367437        }
    368438
     
    372442        signed int _index19 = 0;
    373443        for (;(_index19<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index19))) {
    374             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index19)])))) /* ?{} */);
     444            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index19)]) /* ?{} */);
    375445        }
    376446
     
    387457        signed int _index20 = 0;
    388458        for (;(_index20<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index20))) {
    389             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index20)])))=__separator__A0c_1[((signed long int )_index20)]) /* ?{} */);
     459            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[((signed long int )_index20)]=__separator__A0c_1[((signed long int )_index20)]) /* ?{} */);
    390460        }
    391461
     
    395465        signed int _index21 = 0;
    396466        for (;(_index21<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index21))) {
    397             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index21)])))=__tupleSeparator__A0c_1[((signed long int )_index21)]) /* ?{} */);
    398         }
    399 
    400     }
    401 
    402 }
    403 _Bool __sepPrt__Fb_R9sofstream__1(struct ofstream *__anonymous_object1351);
    404 void __sepReset__F_R9sofstream__1(struct ofstream *__anonymous_object1352);
    405 void __sepReset__F_R9sofstreamb__1(struct ofstream *__anonymous_object1353, _Bool __anonymous_object1354);
    406 const char *__sepGetCur__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1355);
    407 void __sepSetCur__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1356, const char *__anonymous_object1357);
    408 _Bool __getNL__Fb_R9sofstream__1(struct ofstream *__anonymous_object1358);
    409 void __setNL__F_R9sofstreamb__1(struct ofstream *__anonymous_object1359, _Bool __anonymous_object1360);
    410 void __sepOn__F_R9sofstream__1(struct ofstream *__anonymous_object1361);
    411 void __sepOff__F_R9sofstream__1(struct ofstream *__anonymous_object1362);
    412 _Bool __sepDisable__Fb_R9sofstream__1(struct ofstream *__anonymous_object1363);
    413 _Bool __sepEnable__Fb_R9sofstream__1(struct ofstream *__anonymous_object1364);
    414 const char *__sepGet__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1365);
    415 void __sepSet__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1366, const char *__anonymous_object1367);
    416 const char *__sepGetTuple__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1368);
    417 void __sepSetTuple__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1369, const char *__anonymous_object1370);
    418 signed int __fail__Fi_R9sofstream__1(struct ofstream *__anonymous_object1371);
    419 signed int __flush__Fi_R9sofstream__1(struct ofstream *__anonymous_object1372);
    420 void __open__F_R9sofstreamPCcPCc__1(struct ofstream *__anonymous_object1373, const char *__name__PCc_1, const char *__mode__PCc_1);
    421 void __open__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1374, const char *__name__PCc_1);
    422 void __close__F_R9sofstream__1(struct ofstream *__anonymous_object1375);
    423 struct ofstream *__write__FR9sofstream_R9sofstreamPCcUl__1(struct ofstream *__anonymous_object1376, const char *__data__PCc_1, unsigned long int __size__Ul_1);
    424 signed int __fmt__Fi_R9sofstreamPCc__1(struct ofstream *__anonymous_object1377, const char *__fmt__PCc_1, ...);
     467            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[((signed long int )_index21)]=__tupleSeparator__A0c_1[((signed long int )_index21)]) /* ?{} */);
     468        }
     469
     470    }
     471
     472}
     473_Bool __sepPrt__Fb_R9sofstream__1(struct ofstream *__anonymous_object1405);
     474void __sepReset__F_R9sofstream__1(struct ofstream *__anonymous_object1406);
     475void __sepReset__F_R9sofstreamb__1(struct ofstream *__anonymous_object1407, _Bool __anonymous_object1408);
     476const char *__sepGetCur__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1409);
     477void __sepSetCur__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1410, const char *__anonymous_object1411);
     478_Bool __getNL__Fb_R9sofstream__1(struct ofstream *__anonymous_object1412);
     479void __setNL__F_R9sofstreamb__1(struct ofstream *__anonymous_object1413, _Bool __anonymous_object1414);
     480void __sepOn__F_R9sofstream__1(struct ofstream *__anonymous_object1415);
     481void __sepOff__F_R9sofstream__1(struct ofstream *__anonymous_object1416);
     482_Bool __sepDisable__Fb_R9sofstream__1(struct ofstream *__anonymous_object1417);
     483_Bool __sepEnable__Fb_R9sofstream__1(struct ofstream *__anonymous_object1418);
     484const char *__sepGet__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1419);
     485void __sepSet__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1420, const char *__anonymous_object1421);
     486const char *__sepGetTuple__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1422);
     487void __sepSetTuple__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1423, const char *__anonymous_object1424);
     488signed int __fail__Fi_R9sofstream__1(struct ofstream *__anonymous_object1425);
     489signed int __flush__Fi_R9sofstream__1(struct ofstream *__anonymous_object1426);
     490void __open__F_R9sofstreamPCcPCc__1(struct ofstream *__anonymous_object1427, const char *__name__PCc_1, const char *__mode__PCc_1);
     491void __open__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1428, const char *__name__PCc_1);
     492void __close__F_R9sofstream__1(struct ofstream *__anonymous_object1429);
     493struct ofstream *__write__FR9sofstream_R9sofstreamPCcUl__1(struct ofstream *__anonymous_object1430, const char *__data__PCc_1, unsigned long int __size__Ul_1);
     494signed int __fmt__Fi_R9sofstreamPCc__1(struct ofstream *__anonymous_object1431, const char *__fmt__PCc_1, ...);
    425495void ___constructor__F_R9sofstream__1(struct ofstream *__os__R9sofstream_1);
    426496void ___constructor__F_R9sofstreamPCcPCc__1(struct ofstream *__os__R9sofstream_1, const char *__name__PCc_1, const char *__mode__PCc_1);
     
    461531struct ifstream *__read__FR9sifstream_R9sifstreamPcUl__1(struct ifstream *__is__R9sifstream_1, char *__data__Pc_1, unsigned long int __size__Ul_1);
    462532struct ifstream *__ungetc__FR9sifstream_R9sifstreamc__1(struct ifstream *__is__R9sifstream_1, char __c__c_1);
    463 signed int __fmt__Fi_R9sifstreamPCc__1(struct ifstream *__anonymous_object1378, const char *__fmt__PCc_1, ...);
     533signed int __fmt__Fi_R9sifstreamPCc__1(struct ifstream *__anonymous_object1432, const char *__fmt__PCc_1, ...);
    464534void ___constructor__F_R9sifstream__1(struct ifstream *__is__R9sifstream_1);
    465535void ___constructor__F_R9sifstreamPCcPCc__1(struct ifstream *__is__R9sifstream_1, const char *__name__PCc_1, const char *__mode__PCc_1);
     
    471541    struct ofstream *_tmp_cp_ret4;
    472542    __attribute__ ((unused)) struct ofstream *_thunk0(struct ofstream *_p0){
    473         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1379))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1380))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1381, _Bool __anonymous_object1382))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1383))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1384, const char *__anonymous_object1385))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1386))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1387, _Bool __anonymous_object1388))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1389))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1390))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1391))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1392))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1393))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1394, const char *__anonymous_object1395))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1396))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1397, const char *__anonymous_object1398))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1399))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1400))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1401, const char *__anonymous_object1402, unsigned long int __anonymous_object1403))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1404, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    474     }
    475     ((void)(((void)(_tmp_cp_ret4=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1405))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1406))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1407, _Bool __anonymous_object1408))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1409))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1410, const char *__anonymous_object1411))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1412))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1413, _Bool __anonymous_object1414))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1415))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1416))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1417))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1418))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1419))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1420, const char *__anonymous_object1421))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1422))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1423, const char *__anonymous_object1424))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1425))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1426))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1427, const char *__anonymous_object1428, unsigned long int __anonymous_object1429))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1430, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret3=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0c__1(((_Bool (*)(void *__anonymous_object1431))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1432))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1433, _Bool __anonymous_object1434))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1435))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1436, const char *__anonymous_object1437))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1438))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1439, _Bool __anonymous_object1440))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1441))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1442))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1443))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1444))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1445))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1446, const char *__anonymous_object1447))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1448))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1449, const char *__anonymous_object1450))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1451))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1452))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1453, const char *__anonymous_object1454, unsigned long int __anonymous_object1455))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1456, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret2=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1457))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1458))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1459, _Bool __anonymous_object1460))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1461))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1462, const char *__anonymous_object1463))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1464))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1465, _Bool __anonymous_object1466))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1467))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1468))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1469))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1470))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1471))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1472, const char *__anonymous_object1473))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1474))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1475, const char *__anonymous_object1476))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1477))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1478))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1479, const char *__anonymous_object1480, unsigned long int __anonymous_object1481))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1482, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "char ")))) , _tmp_cp_ret2)), __v__c_1)))) , _tmp_cp_ret3)), ((void *(*)(void *__anonymous_object1483))(&_thunk0)))))) , _tmp_cp_ret4));
     543        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1433))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1434))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1435, _Bool __anonymous_object1436))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1437))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1438, const char *__anonymous_object1439))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1440))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1441, _Bool __anonymous_object1442))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1443))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1444))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1445))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1446))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1447))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1448, const char *__anonymous_object1449))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1450))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1451, const char *__anonymous_object1452))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1453))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1454))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1455, const char *__anonymous_object1456, unsigned long int __anonymous_object1457))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1458, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     544    }
     545    ((void)(((void)(_tmp_cp_ret4=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1459))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1460))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1461, _Bool __anonymous_object1462))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1463))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1464, const char *__anonymous_object1465))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1466))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1467, _Bool __anonymous_object1468))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1469))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1470))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1471))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1472))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1473))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1474, const char *__anonymous_object1475))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1476))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1477, const char *__anonymous_object1478))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1479))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1480))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1481, const char *__anonymous_object1482, unsigned long int __anonymous_object1483))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1484, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret3=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0c__1(((_Bool (*)(void *__anonymous_object1485))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1486))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1487, _Bool __anonymous_object1488))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1489))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1490, const char *__anonymous_object1491))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1492))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1493, _Bool __anonymous_object1494))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1495))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1496))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1497))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1498))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1499))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1500, const char *__anonymous_object1501))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1502))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1503, const char *__anonymous_object1504))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1505))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1506))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1507, const char *__anonymous_object1508, unsigned long int __anonymous_object1509))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1510, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret2=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1511))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1512))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1513, _Bool __anonymous_object1514))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1515))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1516, const char *__anonymous_object1517))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1518))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1519, _Bool __anonymous_object1520))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1521))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1522))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1523))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1524))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1525))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1526, const char *__anonymous_object1527))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1528))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1529, const char *__anonymous_object1530))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1531))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1532))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1533, const char *__anonymous_object1534, unsigned long int __anonymous_object1535))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1536, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "char "))) , _tmp_cp_ret2)), __v__c_1))) , _tmp_cp_ret3)), ((void *(*)(void *__anonymous_object1537))(&_thunk0))))) , _tmp_cp_ret4));
    476546}
    477547void __f__F_Sc__1(signed char __v__Sc_1){
     
    480550    struct ofstream *_tmp_cp_ret7;
    481551    __attribute__ ((unused)) struct ofstream *_thunk1(struct ofstream *_p0){
    482         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1484))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1485))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1486, _Bool __anonymous_object1487))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1488))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1489, const char *__anonymous_object1490))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1491))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1492, _Bool __anonymous_object1493))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1494))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1495))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1496))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1497))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1498))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1499, const char *__anonymous_object1500))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1501))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1502, const char *__anonymous_object1503))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1504))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1505))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1506, const char *__anonymous_object1507, unsigned long int __anonymous_object1508))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1509, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    483     }
    484     ((void)(((void)(_tmp_cp_ret7=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1510))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1511))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1512, _Bool __anonymous_object1513))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1514))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1515, const char *__anonymous_object1516))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1517))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1518, _Bool __anonymous_object1519))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1520))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1521))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1522))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1523))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1524))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1525, const char *__anonymous_object1526))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1527))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1528, const char *__anonymous_object1529))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1530))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1531))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1532, const char *__anonymous_object1533, unsigned long int __anonymous_object1534))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1535, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret6=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Sc__1(((_Bool (*)(void *__anonymous_object1536))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1537))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1538, _Bool __anonymous_object1539))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1540))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1541, const char *__anonymous_object1542))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1543))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1544, _Bool __anonymous_object1545))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1546))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1547))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1548))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1549))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1550))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1551, const char *__anonymous_object1552))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1553))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1554, const char *__anonymous_object1555))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1556))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1557))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1558, const char *__anonymous_object1559, unsigned long int __anonymous_object1560))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1561, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret5=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1562))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1563))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1564, _Bool __anonymous_object1565))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1566))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1567, const char *__anonymous_object1568))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1569))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1570, _Bool __anonymous_object1571))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1572))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1573))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1574))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1575))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1576))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1577, const char *__anonymous_object1578))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1579))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1580, const char *__anonymous_object1581))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1582))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1583))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1584, const char *__anonymous_object1585, unsigned long int __anonymous_object1586))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1587, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "signed char ")))) , _tmp_cp_ret5)), __v__Sc_1)))) , _tmp_cp_ret6)), ((void *(*)(void *__anonymous_object1588))(&_thunk1)))))) , _tmp_cp_ret7));
     552        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1538))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1539))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1540, _Bool __anonymous_object1541))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1542))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1543, const char *__anonymous_object1544))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1545))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1546, _Bool __anonymous_object1547))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1548))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1549))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1550))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1551))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1552))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1553, const char *__anonymous_object1554))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1555))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1556, const char *__anonymous_object1557))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1558))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1559))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1560, const char *__anonymous_object1561, unsigned long int __anonymous_object1562))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1563, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     553    }
     554    ((void)(((void)(_tmp_cp_ret7=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1564))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1565))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1566, _Bool __anonymous_object1567))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1568))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1569, const char *__anonymous_object1570))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1571))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1572, _Bool __anonymous_object1573))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1574))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1575))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1576))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1577))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1578))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1579, const char *__anonymous_object1580))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1581))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1582, const char *__anonymous_object1583))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1584))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1585))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1586, const char *__anonymous_object1587, unsigned long int __anonymous_object1588))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1589, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret6=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Sc__1(((_Bool (*)(void *__anonymous_object1590))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1591))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1592, _Bool __anonymous_object1593))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1594))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1595, const char *__anonymous_object1596))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1597))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1598, _Bool __anonymous_object1599))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1600))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1601))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1602))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1603))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1604))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1605, const char *__anonymous_object1606))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1607))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1608, const char *__anonymous_object1609))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1610))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1611))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1612, const char *__anonymous_object1613, unsigned long int __anonymous_object1614))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1615, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret5=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1616))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1617))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1618, _Bool __anonymous_object1619))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1620))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1621, const char *__anonymous_object1622))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1623))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1624, _Bool __anonymous_object1625))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1626))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1627))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1628))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1629))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1630))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1631, const char *__anonymous_object1632))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1633))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1634, const char *__anonymous_object1635))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1636))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1637))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1638, const char *__anonymous_object1639, unsigned long int __anonymous_object1640))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1641, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "signed char "))) , _tmp_cp_ret5)), __v__Sc_1))) , _tmp_cp_ret6)), ((void *(*)(void *__anonymous_object1642))(&_thunk1))))) , _tmp_cp_ret7));
    485555}
    486556void __f__F_Uc__1(unsigned char __v__Uc_1){
     
    489559    struct ofstream *_tmp_cp_ret10;
    490560    __attribute__ ((unused)) struct ofstream *_thunk2(struct ofstream *_p0){
    491         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1589))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1590))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1591, _Bool __anonymous_object1592))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1593))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1594, const char *__anonymous_object1595))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1596))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1597, _Bool __anonymous_object1598))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1599))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1600))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1601))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1602))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1603))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1604, const char *__anonymous_object1605))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1606))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1607, const char *__anonymous_object1608))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1609))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1610))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1611, const char *__anonymous_object1612, unsigned long int __anonymous_object1613))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1614, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    492     }
    493     ((void)(((void)(_tmp_cp_ret10=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1615))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1616))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1617, _Bool __anonymous_object1618))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1619))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1620, const char *__anonymous_object1621))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1622))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1623, _Bool __anonymous_object1624))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1625))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1626))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1627))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1628))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1629))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1630, const char *__anonymous_object1631))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1632))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1633, const char *__anonymous_object1634))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1635))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1636))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1637, const char *__anonymous_object1638, unsigned long int __anonymous_object1639))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1640, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret9=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Uc__1(((_Bool (*)(void *__anonymous_object1641))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1642))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1643, _Bool __anonymous_object1644))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1645))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1646, const char *__anonymous_object1647))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1648))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1649, _Bool __anonymous_object1650))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1651))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1652))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1653))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1654))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1655))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1656, const char *__anonymous_object1657))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1658))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1659, const char *__anonymous_object1660))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1661))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1662))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1663, const char *__anonymous_object1664, unsigned long int __anonymous_object1665))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1666, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret8=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1667))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1668))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1669, _Bool __anonymous_object1670))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1671))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1672, const char *__anonymous_object1673))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1674))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1675, _Bool __anonymous_object1676))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1677))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1678))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1679))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1680))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1681))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1682, const char *__anonymous_object1683))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1684))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1685, const char *__anonymous_object1686))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1687))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1688))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1689, const char *__anonymous_object1690, unsigned long int __anonymous_object1691))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1692, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "unsigned char ")))) , _tmp_cp_ret8)), __v__Uc_1)))) , _tmp_cp_ret9)), ((void *(*)(void *__anonymous_object1693))(&_thunk2)))))) , _tmp_cp_ret10));
     561        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1643))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1644))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1645, _Bool __anonymous_object1646))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1647))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1648, const char *__anonymous_object1649))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1650))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1651, _Bool __anonymous_object1652))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1653))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1654))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1655))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1656))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1657))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1658, const char *__anonymous_object1659))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1660))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1661, const char *__anonymous_object1662))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1663))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1664))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1665, const char *__anonymous_object1666, unsigned long int __anonymous_object1667))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1668, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     562    }
     563    ((void)(((void)(_tmp_cp_ret10=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1669))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1670))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1671, _Bool __anonymous_object1672))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1673))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1674, const char *__anonymous_object1675))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1676))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1677, _Bool __anonymous_object1678))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1679))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1680))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1681))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1682))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1683))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1684, const char *__anonymous_object1685))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1686))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1687, const char *__anonymous_object1688))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1689))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1690))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1691, const char *__anonymous_object1692, unsigned long int __anonymous_object1693))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1694, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret9=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Uc__1(((_Bool (*)(void *__anonymous_object1695))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1696))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1697, _Bool __anonymous_object1698))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1699))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1700, const char *__anonymous_object1701))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1702))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1703, _Bool __anonymous_object1704))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1705))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1706))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1707))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1708))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1709))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1710, const char *__anonymous_object1711))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1712))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1713, const char *__anonymous_object1714))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1715))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1716))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1717, const char *__anonymous_object1718, unsigned long int __anonymous_object1719))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1720, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret8=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1721))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1722))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1723, _Bool __anonymous_object1724))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1725))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1726, const char *__anonymous_object1727))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1728))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1729, _Bool __anonymous_object1730))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1731))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1732))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1733))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1734))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1735))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1736, const char *__anonymous_object1737))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1738))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1739, const char *__anonymous_object1740))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1741))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1742))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1743, const char *__anonymous_object1744, unsigned long int __anonymous_object1745))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1746, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "unsigned char "))) , _tmp_cp_ret8)), __v__Uc_1))) , _tmp_cp_ret9)), ((void *(*)(void *__anonymous_object1747))(&_thunk2))))) , _tmp_cp_ret10));
    494564}
    495565void __f__F_s__1(signed short int __v__s_1){
     
    498568    struct ofstream *_tmp_cp_ret13;
    499569    __attribute__ ((unused)) struct ofstream *_thunk3(struct ofstream *_p0){
    500         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1694))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1695))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1696, _Bool __anonymous_object1697))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1698))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1699, const char *__anonymous_object1700))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1701))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1702, _Bool __anonymous_object1703))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1704))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1705))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1706))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1707))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1708))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1709, const char *__anonymous_object1710))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1711))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1712, const char *__anonymous_object1713))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1714))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1715))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1716, const char *__anonymous_object1717, unsigned long int __anonymous_object1718))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1719, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    501     }
    502     ((void)(((void)(_tmp_cp_ret13=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1720))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1721))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1722, _Bool __anonymous_object1723))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1724))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1725, const char *__anonymous_object1726))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1727))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1728, _Bool __anonymous_object1729))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1730))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1731))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1732))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1733))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1734))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1735, const char *__anonymous_object1736))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1737))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1738, const char *__anonymous_object1739))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1740))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1741))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1742, const char *__anonymous_object1743, unsigned long int __anonymous_object1744))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1745, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret12=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0s__1(((_Bool (*)(void *__anonymous_object1746))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1747))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1748, _Bool __anonymous_object1749))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1750))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1751, const char *__anonymous_object1752))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1753))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1754, _Bool __anonymous_object1755))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1756))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1757))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1758))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1759))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1760))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1761, const char *__anonymous_object1762))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1763))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1764, const char *__anonymous_object1765))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1766))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1767))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1768, const char *__anonymous_object1769, unsigned long int __anonymous_object1770))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1771, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret11=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1772))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1773))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1774, _Bool __anonymous_object1775))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1776))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1777, const char *__anonymous_object1778))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1779))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1780, _Bool __anonymous_object1781))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1782))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1783))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1784))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1785))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1786))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1787, const char *__anonymous_object1788))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1789))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1790, const char *__anonymous_object1791))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1792))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1793))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1794, const char *__anonymous_object1795, unsigned long int __anonymous_object1796))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1797, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "signed short int")))) , _tmp_cp_ret11)), __v__s_1)))) , _tmp_cp_ret12)), ((void *(*)(void *__anonymous_object1798))(&_thunk3)))))) , _tmp_cp_ret13));
     570        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1748))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1749))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1750, _Bool __anonymous_object1751))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1752))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1753, const char *__anonymous_object1754))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1755))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1756, _Bool __anonymous_object1757))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1758))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1759))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1760))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1761))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1762))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1763, const char *__anonymous_object1764))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1765))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1766, const char *__anonymous_object1767))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1768))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1769))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1770, const char *__anonymous_object1771, unsigned long int __anonymous_object1772))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1773, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     571    }
     572    ((void)(((void)(_tmp_cp_ret13=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1774))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1775))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1776, _Bool __anonymous_object1777))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1778))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1779, const char *__anonymous_object1780))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1781))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1782, _Bool __anonymous_object1783))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1784))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1785))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1786))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1787))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1788))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1789, const char *__anonymous_object1790))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1791))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1792, const char *__anonymous_object1793))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1794))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1795))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1796, const char *__anonymous_object1797, unsigned long int __anonymous_object1798))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1799, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret12=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0s__1(((_Bool (*)(void *__anonymous_object1800))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1801))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1802, _Bool __anonymous_object1803))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1804))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1805, const char *__anonymous_object1806))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1807))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1808, _Bool __anonymous_object1809))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1810))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1811))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1812))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1813))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1814))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1815, const char *__anonymous_object1816))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1817))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1818, const char *__anonymous_object1819))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1820))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1821))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1822, const char *__anonymous_object1823, unsigned long int __anonymous_object1824))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1825, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret11=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1826))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1827))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1828, _Bool __anonymous_object1829))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1830))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1831, const char *__anonymous_object1832))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1833))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1834, _Bool __anonymous_object1835))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1836))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1837))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1838))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1839))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1840))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1841, const char *__anonymous_object1842))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1843))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1844, const char *__anonymous_object1845))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1846))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1847))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1848, const char *__anonymous_object1849, unsigned long int __anonymous_object1850))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1851, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "signed short int"))) , _tmp_cp_ret11)), __v__s_1))) , _tmp_cp_ret12)), ((void *(*)(void *__anonymous_object1852))(&_thunk3))))) , _tmp_cp_ret13));
    503573}
    504574void __f__F_Us__1(unsigned short int __v__Us_1){
     
    507577    struct ofstream *_tmp_cp_ret16;
    508578    __attribute__ ((unused)) struct ofstream *_thunk4(struct ofstream *_p0){
    509         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1799))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1800))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1801, _Bool __anonymous_object1802))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1803))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1804, const char *__anonymous_object1805))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1806))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1807, _Bool __anonymous_object1808))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1809))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1810))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1811))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1812))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1813))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1814, const char *__anonymous_object1815))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1816))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1817, const char *__anonymous_object1818))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1819))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1820))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1821, const char *__anonymous_object1822, unsigned long int __anonymous_object1823))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1824, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    510     }
    511     ((void)(((void)(_tmp_cp_ret16=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1825))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1826))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1827, _Bool __anonymous_object1828))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1829))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1830, const char *__anonymous_object1831))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1832))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1833, _Bool __anonymous_object1834))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1835))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1836))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1837))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1838))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1839))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1840, const char *__anonymous_object1841))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1842))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1843, const char *__anonymous_object1844))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1845))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1846))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1847, const char *__anonymous_object1848, unsigned long int __anonymous_object1849))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1850, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret15=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Us__1(((_Bool (*)(void *__anonymous_object1851))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1852))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1853, _Bool __anonymous_object1854))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1855))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1856, const char *__anonymous_object1857))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1858))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1859, _Bool __anonymous_object1860))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1861))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1862))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1863))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1864))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1865))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1866, const char *__anonymous_object1867))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1868))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1869, const char *__anonymous_object1870))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1871))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1872))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1873, const char *__anonymous_object1874, unsigned long int __anonymous_object1875))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1876, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret14=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1877))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1878))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1879, _Bool __anonymous_object1880))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1881))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1882, const char *__anonymous_object1883))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1884))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1885, _Bool __anonymous_object1886))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1887))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1888))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1889))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1890))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1891))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1892, const char *__anonymous_object1893))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1894))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1895, const char *__anonymous_object1896))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1897))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1898))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1899, const char *__anonymous_object1900, unsigned long int __anonymous_object1901))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1902, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "unsigned short int")))) , _tmp_cp_ret14)), __v__Us_1)))) , _tmp_cp_ret15)), ((void *(*)(void *__anonymous_object1903))(&_thunk4)))))) , _tmp_cp_ret16));
     579        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1853))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1854))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1855, _Bool __anonymous_object1856))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1857))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1858, const char *__anonymous_object1859))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1860))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1861, _Bool __anonymous_object1862))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1863))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1864))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1865))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1866))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1867))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1868, const char *__anonymous_object1869))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1870))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1871, const char *__anonymous_object1872))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1873))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1874))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1875, const char *__anonymous_object1876, unsigned long int __anonymous_object1877))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1878, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     580    }
     581    ((void)(((void)(_tmp_cp_ret16=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1879))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1880))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1881, _Bool __anonymous_object1882))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1883))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1884, const char *__anonymous_object1885))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1886))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1887, _Bool __anonymous_object1888))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1889))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1890))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1891))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1892))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1893))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1894, const char *__anonymous_object1895))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1896))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1897, const char *__anonymous_object1898))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1899))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1900))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1901, const char *__anonymous_object1902, unsigned long int __anonymous_object1903))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1904, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret15=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Us__1(((_Bool (*)(void *__anonymous_object1905))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1906))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1907, _Bool __anonymous_object1908))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1909))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1910, const char *__anonymous_object1911))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1912))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1913, _Bool __anonymous_object1914))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1915))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1916))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1917))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1918))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1919))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1920, const char *__anonymous_object1921))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1922))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1923, const char *__anonymous_object1924))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1925))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1926))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1927, const char *__anonymous_object1928, unsigned long int __anonymous_object1929))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1930, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret14=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1931))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1932))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1933, _Bool __anonymous_object1934))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1935))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1936, const char *__anonymous_object1937))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1938))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1939, _Bool __anonymous_object1940))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1941))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1942))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1943))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1944))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1945))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1946, const char *__anonymous_object1947))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1948))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1949, const char *__anonymous_object1950))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1951))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1952))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1953, const char *__anonymous_object1954, unsigned long int __anonymous_object1955))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1956, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "unsigned short int"))) , _tmp_cp_ret14)), __v__Us_1))) , _tmp_cp_ret15)), ((void *(*)(void *__anonymous_object1957))(&_thunk4))))) , _tmp_cp_ret16));
    512582}
    513583void __f__F_Ul__1(unsigned long int __v__Ul_1){
     
    516586    struct ofstream *_tmp_cp_ret19;
    517587    __attribute__ ((unused)) struct ofstream *_thunk5(struct ofstream *_p0){
    518         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1904))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1905))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1906, _Bool __anonymous_object1907))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1908))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1909, const char *__anonymous_object1910))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1911))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1912, _Bool __anonymous_object1913))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1914))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1915))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1916))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1917))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1918))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1919, const char *__anonymous_object1920))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1921))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1922, const char *__anonymous_object1923))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1924))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1925))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1926, const char *__anonymous_object1927, unsigned long int __anonymous_object1928))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1929, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    519     }
    520     ((void)(((void)(_tmp_cp_ret19=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1930))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1931))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1932, _Bool __anonymous_object1933))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1934))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1935, const char *__anonymous_object1936))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1937))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1938, _Bool __anonymous_object1939))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1940))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1941))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1942))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1943))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1944))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1945, const char *__anonymous_object1946))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1947))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1948, const char *__anonymous_object1949))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1950))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1951))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1952, const char *__anonymous_object1953, unsigned long int __anonymous_object1954))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1955, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret18=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Ul__1(((_Bool (*)(void *__anonymous_object1956))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1957))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1958, _Bool __anonymous_object1959))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1960))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1961, const char *__anonymous_object1962))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1963))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1964, _Bool __anonymous_object1965))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1966))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1967))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1968))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1969))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1970))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1971, const char *__anonymous_object1972))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1973))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1974, const char *__anonymous_object1975))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1976))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1977))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1978, const char *__anonymous_object1979, unsigned long int __anonymous_object1980))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1981, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret17=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1982))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1983))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1984, _Bool __anonymous_object1985))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1986))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1987, const char *__anonymous_object1988))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1989))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1990, _Bool __anonymous_object1991))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1992))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1993))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1994))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1995))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1996))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1997, const char *__anonymous_object1998))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1999))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2000, const char *__anonymous_object2001))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object2002))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object2003))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object2004, const char *__anonymous_object2005, unsigned long int __anonymous_object2006))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object2007, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "size_t")))) , _tmp_cp_ret17)), __v__Ul_1)))) , _tmp_cp_ret18)), ((void *(*)(void *__anonymous_object2008))(&_thunk5)))))) , _tmp_cp_ret19));
     588        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1958))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1959))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1960, _Bool __anonymous_object1961))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1962))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1963, const char *__anonymous_object1964))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1965))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1966, _Bool __anonymous_object1967))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1968))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1969))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1970))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1971))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1972))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1973, const char *__anonymous_object1974))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1975))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1976, const char *__anonymous_object1977))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1978))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1979))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1980, const char *__anonymous_object1981, unsigned long int __anonymous_object1982))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1983, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     589    }
     590    ((void)(((void)(_tmp_cp_ret19=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1984))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1985))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1986, _Bool __anonymous_object1987))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1988))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1989, const char *__anonymous_object1990))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1991))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1992, _Bool __anonymous_object1993))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1994))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1995))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1996))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1997))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1998))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1999, const char *__anonymous_object2000))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object2001))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2002, const char *__anonymous_object2003))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object2004))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object2005))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object2006, const char *__anonymous_object2007, unsigned long int __anonymous_object2008))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object2009, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret18=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Ul__1(((_Bool (*)(void *__anonymous_object2010))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object2011))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object2012, _Bool __anonymous_object2013))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object2014))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2015, const char *__anonymous_object2016))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object2017))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object2018, _Bool __anonymous_object2019))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object2020))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object2021))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object2022))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object2023))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object2024))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2025, const char *__anonymous_object2026))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object2027))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2028, const char *__anonymous_object2029))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object2030))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object2031))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object2032, const char *__anonymous_object2033, unsigned long int __anonymous_object2034))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object2035, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret17=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object2036))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object2037))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object2038, _Bool __anonymous_object2039))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object2040))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2041, const char *__anonymous_object2042))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object2043))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object2044, _Bool __anonymous_object2045))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object2046))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object2047))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object2048))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object2049))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object2050))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2051, const char *__anonymous_object2052))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object2053))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2054, const char *__anonymous_object2055))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object2056))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object2057))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object2058, const char *__anonymous_object2059, unsigned long int __anonymous_object2060))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object2061, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "size_t"))) , _tmp_cp_ret17)), __v__Ul_1))) , _tmp_cp_ret18)), ((void *(*)(void *__anonymous_object2062))(&_thunk5))))) , _tmp_cp_ret19));
    521591}
    522592signed int __main__Fi___1(){
  • src/tests/.expect/literals.x86.txt

    r2efe4b8 r1cdfa82  
    122122struct _Istream_cstrC __cstr__F15s_Istream_cstrC_Pci__1(char *__anonymous_object1340, signed int __size__i_1);
    123123void *___operator_bitor__A0_1_0_0___fail__PFi_Rd0___eof__PFi_Rd0___open__PF_Rd0PCc___close__PF_Rd0___read__PFRd0_Rd0PcUl___ungetc__PFRd0_Rd0c___fmt__PFi_Rd0PCc__FRd0_Rd015s_Istream_cstrC__1(__attribute__ ((unused)) signed int (*__fail__PFi_R7tistype__1)(void *__anonymous_object1341), __attribute__ ((unused)) signed int (*__eof__PFi_R7tistype__1)(void *__anonymous_object1342), __attribute__ ((unused)) void (*__open__PF_R7tistypePCc__1)(void *__is__R7tistype_1, const char *__name__PCc_1), __attribute__ ((unused)) void (*__close__PF_R7tistype__1)(void *__is__R7tistype_1), __attribute__ ((unused)) void *(*__read__PFR7tistype_R7tistypePcUl__1)(void *__anonymous_object1343, char *__anonymous_object1344, unsigned long int __anonymous_object1345), __attribute__ ((unused)) void *(*__ungetc__PFR7tistype_R7tistypec__1)(void *__anonymous_object1346, char __anonymous_object1347), __attribute__ ((unused)) signed int (*__fmt__PFi_R7tistypePCc__1)(void *__anonymous_object1348, const char *__fmt__PCc_1, ...), void *__anonymous_object1349, struct _Istream_cstrC __anonymous_object1350);
     124struct Duration {
     125    signed long long int __tv__q_1;
     126};
     127static inline void ___constructor__F_R9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1);
     128static inline void ___constructor__F_R9sDuration9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1, struct Duration ___src__9sDuration_1);
     129static inline void ___destructor__F_R9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1);
     130static inline struct Duration ___operator_assign__F9sDuration_R9sDuration9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1, struct Duration ___src__9sDuration_1);
     131static inline void ___constructor__F_R9sDurationq_autogen___1(struct Duration *___dst__R9sDuration_1, signed long long int __tv__q_1);
     132static inline void ___constructor__F_R9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1){
     133    ((void)((*___dst__R9sDuration_1).__tv__q_1) /* ?{} */);
     134}
     135static inline void ___constructor__F_R9sDuration9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1, struct Duration ___src__9sDuration_1){
     136    ((void)((*___dst__R9sDuration_1).__tv__q_1=___src__9sDuration_1.__tv__q_1) /* ?{} */);
     137}
     138static inline void ___destructor__F_R9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1){
     139    ((void)((*___dst__R9sDuration_1).__tv__q_1) /* ^?{} */);
     140}
     141static inline struct Duration ___operator_assign__F9sDuration_R9sDuration9sDuration_autogen___1(struct Duration *___dst__R9sDuration_1, struct Duration ___src__9sDuration_1){
     142    struct Duration ___ret__9sDuration_1;
     143    ((void)((*___dst__R9sDuration_1).__tv__q_1=___src__9sDuration_1.__tv__q_1));
     144    ((void)___constructor__F_R9sDuration9sDuration_autogen___1((&___ret__9sDuration_1), (*___dst__R9sDuration_1)));
     145    return ___ret__9sDuration_1;
     146}
     147static inline void ___constructor__F_R9sDurationq_autogen___1(struct Duration *___dst__R9sDuration_1, signed long long int __tv__q_1){
     148    ((void)((*___dst__R9sDuration_1).__tv__q_1=__tv__q_1) /* ?{} */);
     149}
     150static inline void ___constructor__F_R9sDuration__1(struct Duration *__dur__R9sDuration_1){
     151    ((void)((*__dur__R9sDuration_1).__tv__q_1) /* ?{} */);
     152    ((void)((*__dur__R9sDuration_1).__tv__q_1=((signed long long int )0)));
     153}
     154static inline void ___constructor__F_R9sDurationZ__1(struct Duration *__dur__R9sDuration_1, long int __anonymous_object1351){
     155    ((void)((*__dur__R9sDuration_1).__tv__q_1) /* ?{} */);
     156    ((void)((*__dur__R9sDuration_1).__tv__q_1=((signed long long int )0)));
     157}
     158struct Time {
     159    unsigned long long int __tv__Uq_1;
     160};
     161static inline void ___constructor__F_R5sTime_autogen___1(struct Time *___dst__R5sTime_1);
     162static inline void ___constructor__F_R5sTime5sTime_autogen___1(struct Time *___dst__R5sTime_1, struct Time ___src__5sTime_1);
     163static inline void ___destructor__F_R5sTime_autogen___1(struct Time *___dst__R5sTime_1);
     164static inline struct Time ___operator_assign__F5sTime_R5sTime5sTime_autogen___1(struct Time *___dst__R5sTime_1, struct Time ___src__5sTime_1);
     165static inline void ___constructor__F_R5sTimeUq_autogen___1(struct Time *___dst__R5sTime_1, unsigned long long int __tv__Uq_1);
     166static inline void ___constructor__F_R5sTime_autogen___1(struct Time *___dst__R5sTime_1){
     167    ((void)((*___dst__R5sTime_1).__tv__Uq_1) /* ?{} */);
     168}
     169static inline void ___constructor__F_R5sTime5sTime_autogen___1(struct Time *___dst__R5sTime_1, struct Time ___src__5sTime_1){
     170    ((void)((*___dst__R5sTime_1).__tv__Uq_1=___src__5sTime_1.__tv__Uq_1) /* ?{} */);
     171}
     172static inline void ___destructor__F_R5sTime_autogen___1(struct Time *___dst__R5sTime_1){
     173    ((void)((*___dst__R5sTime_1).__tv__Uq_1) /* ^?{} */);
     174}
     175static inline struct Time ___operator_assign__F5sTime_R5sTime5sTime_autogen___1(struct Time *___dst__R5sTime_1, struct Time ___src__5sTime_1){
     176    struct Time ___ret__5sTime_1;
     177    ((void)((*___dst__R5sTime_1).__tv__Uq_1=___src__5sTime_1.__tv__Uq_1));
     178    ((void)___constructor__F_R5sTime5sTime_autogen___1((&___ret__5sTime_1), (*___dst__R5sTime_1)));
     179    return ___ret__5sTime_1;
     180}
     181static inline void ___constructor__F_R5sTimeUq_autogen___1(struct Time *___dst__R5sTime_1, unsigned long long int __tv__Uq_1){
     182    ((void)((*___dst__R5sTime_1).__tv__Uq_1=__tv__Uq_1) /* ?{} */);
     183}
     184static inline void ___constructor__F_R5sTime__1(struct Time *__time__R5sTime_1){
     185    ((void)((*__time__R5sTime_1).__tv__Uq_1) /* ?{} */);
     186    ((void)((*__time__R5sTime_1).__tv__Uq_1=((unsigned long long int )0)));
     187}
     188static inline void ___constructor__F_R5sTimeZ__1(struct Time *__time__R5sTime_1, long int __anonymous_object1352){
     189    ((void)((*__time__R5sTime_1).__tv__Uq_1) /* ?{} */);
     190    ((void)((*__time__R5sTime_1).__tv__Uq_1=((unsigned long long int )0)));
     191}
     192void *___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd09sDuration__1(__attribute__ ((unused)) _Bool (*__sepPrt__PFb_R7tostype__1)(void *__anonymous_object1353), __attribute__ ((unused)) void (*__sepReset__PF_R7tostype__1)(void *__anonymous_object1354), __attribute__ ((unused)) void (*__sepReset__PF_R7tostypeb__1)(void *__anonymous_object1355, _Bool __anonymous_object1356), __attribute__ ((unused)) const char *(*__sepGetCur__PFPCc_R7tostype__1)(void *__anonymous_object1357), __attribute__ ((unused)) void (*__sepSetCur__PF_R7tostypePCc__1)(void *__anonymous_object1358, const char *__anonymous_object1359), __attribute__ ((unused)) _Bool (*__getNL__PFb_R7tostype__1)(void *__anonymous_object1360), __attribute__ ((unused)) void (*__setNL__PF_R7tostypeb__1)(void *__anonymous_object1361, _Bool __anonymous_object1362), __attribute__ ((unused)) void (*__sepOn__PF_R7tostype__1)(void *__anonymous_object1363), __attribute__ ((unused)) void (*__sepOff__PF_R7tostype__1)(void *__anonymous_object1364), __attribute__ ((unused)) _Bool (*__sepDisable__PFb_R7tostype__1)(void *__anonymous_object1365), __attribute__ ((unused)) _Bool (*__sepEnable__PFb_R7tostype__1)(void *__anonymous_object1366), __attribute__ ((unused)) const char *(*__sepGet__PFPCc_R7tostype__1)(void *__anonymous_object1367), __attribute__ ((unused)) void (*__sepSet__PF_R7tostypePCc__1)(void *__anonymous_object1368, const char *__anonymous_object1369), __attribute__ ((unused)) const char *(*__sepGetTuple__PFPCc_R7tostype__1)(void *__anonymous_object1370), __attribute__ ((unused)) void (*__sepSetTuple__PF_R7tostypePCc__1)(void *__anonymous_object1371, const char *__anonymous_object1372), __attribute__ ((unused)) signed int (*__fail__PFi_R7tostype__1)(void *__anonymous_object1373), __attribute__ ((unused)) signed int (*__flush__PFi_R7tostype__1)(void *__anonymous_object1374), __attribute__ ((unused)) void (*__open__PF_R7tostypePCcPCc__1)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1), __attribute__ ((unused)) void (*__close__PF_R7tostype__1)(void *__os__R7tostype_1), __attribute__ ((unused)) void *(*__write__PFR7tostype_R7tostypePCcUl__1)(void *__anonymous_object1375, const char *__anonymous_object1376, unsigned long int __anonymous_object1377), __attribute__ ((unused)) signed int (*__fmt__PFi_R7tostypePCc__1)(void *__anonymous_object1378, const char *__fmt__PCc_1, ...), void *__os__R7tostype_1, struct Duration __dur__9sDuration_1);
     193void *___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd05sTime__1(__attribute__ ((unused)) _Bool (*__sepPrt__PFb_R7tostype__1)(void *__anonymous_object1379), __attribute__ ((unused)) void (*__sepReset__PF_R7tostype__1)(void *__anonymous_object1380), __attribute__ ((unused)) void (*__sepReset__PF_R7tostypeb__1)(void *__anonymous_object1381, _Bool __anonymous_object1382), __attribute__ ((unused)) const char *(*__sepGetCur__PFPCc_R7tostype__1)(void *__anonymous_object1383), __attribute__ ((unused)) void (*__sepSetCur__PF_R7tostypePCc__1)(void *__anonymous_object1384, const char *__anonymous_object1385), __attribute__ ((unused)) _Bool (*__getNL__PFb_R7tostype__1)(void *__anonymous_object1386), __attribute__ ((unused)) void (*__setNL__PF_R7tostypeb__1)(void *__anonymous_object1387, _Bool __anonymous_object1388), __attribute__ ((unused)) void (*__sepOn__PF_R7tostype__1)(void *__anonymous_object1389), __attribute__ ((unused)) void (*__sepOff__PF_R7tostype__1)(void *__anonymous_object1390), __attribute__ ((unused)) _Bool (*__sepDisable__PFb_R7tostype__1)(void *__anonymous_object1391), __attribute__ ((unused)) _Bool (*__sepEnable__PFb_R7tostype__1)(void *__anonymous_object1392), __attribute__ ((unused)) const char *(*__sepGet__PFPCc_R7tostype__1)(void *__anonymous_object1393), __attribute__ ((unused)) void (*__sepSet__PF_R7tostypePCc__1)(void *__anonymous_object1394, const char *__anonymous_object1395), __attribute__ ((unused)) const char *(*__sepGetTuple__PFPCc_R7tostype__1)(void *__anonymous_object1396), __attribute__ ((unused)) void (*__sepSetTuple__PF_R7tostypePCc__1)(void *__anonymous_object1397, const char *__anonymous_object1398), __attribute__ ((unused)) signed int (*__fail__PFi_R7tostype__1)(void *__anonymous_object1399), __attribute__ ((unused)) signed int (*__flush__PFi_R7tostype__1)(void *__anonymous_object1400), __attribute__ ((unused)) void (*__open__PF_R7tostypePCcPCc__1)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1), __attribute__ ((unused)) void (*__close__PF_R7tostype__1)(void *__os__R7tostype_1), __attribute__ ((unused)) void *(*__write__PFR7tostype_R7tostypePCcUl__1)(void *__anonymous_object1401, const char *__anonymous_object1402, unsigned long int __anonymous_object1403), __attribute__ ((unused)) signed int (*__fmt__PFi_R7tostypePCc__1)(void *__anonymous_object1404, const char *__fmt__PCc_1, ...), void *__os__R7tostype_1, struct Time __time__5sTime_1);
    124194enum __anonymous0 {
    125195    __sepSize__C13e__anonymous0_1 = 16,
     
    154224        signed int _index0 = 0;
    155225        for (;(_index0<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index0))) {
    156             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[_index0])))) /* ?{} */);
     226            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[_index0]) /* ?{} */);
    157227        }
    158228
     
    162232        signed int _index1 = 0;
    163233        for (;(_index1<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index1))) {
    164             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index1])))) /* ?{} */);
     234            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index1]) /* ?{} */);
    165235        }
    166236
     
    177247        signed int _index2 = 0;
    178248        for (;(_index2<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index2))) {
    179             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[_index2])))=___src__9sofstream_1.__separator__A0c_1[_index2]) /* ?{} */);
     249            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[_index2]=___src__9sofstream_1.__separator__A0c_1[_index2]) /* ?{} */);
    180250        }
    181251
     
    185255        signed int _index3 = 0;
    186256        for (;(_index3<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index3))) {
    187             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index3])))=___src__9sofstream_1.__tupleSeparator__A0c_1[_index3]) /* ?{} */);
     257            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index3]=___src__9sofstream_1.__tupleSeparator__A0c_1[_index3]) /* ?{} */);
    188258        }
    189259
     
    195265        signed int _index4 = (((signed int )__sepSize__C13e__anonymous0_1)-1);
    196266        for (;(_index4>=0);((void)(--_index4))) {
    197             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index4])))) /* ^?{} */);
     267            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index4]) /* ^?{} */);
    198268        }
    199269
     
    203273        signed int _index5 = (((signed int )__sepSize__C13e__anonymous0_1)-1);
    204274        for (;(_index5>=0);((void)(--_index5))) {
    205             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[_index5])))) /* ^?{} */);
     275            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[_index5]) /* ^?{} */);
    206276        }
    207277
     
    249319        signed int _index8 = 0;
    250320        for (;(_index8<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index8))) {
    251             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[_index8])))) /* ?{} */);
     321            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[_index8]) /* ?{} */);
    252322        }
    253323
     
    257327        signed int _index9 = 0;
    258328        for (;(_index9<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index9))) {
    259             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index9])))) /* ?{} */);
     329            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index9]) /* ?{} */);
    260330        }
    261331
     
    272342        signed int _index10 = 0;
    273343        for (;(_index10<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index10))) {
    274             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[_index10])))) /* ?{} */);
     344            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[_index10]) /* ?{} */);
    275345        }
    276346
     
    280350        signed int _index11 = 0;
    281351        for (;(_index11<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index11))) {
    282             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index11])))) /* ?{} */);
     352            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index11]) /* ?{} */);
    283353        }
    284354
     
    295365        signed int _index12 = 0;
    296366        for (;(_index12<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index12))) {
    297             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[_index12])))) /* ?{} */);
     367            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[_index12]) /* ?{} */);
    298368        }
    299369
     
    303373        signed int _index13 = 0;
    304374        for (;(_index13<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index13))) {
    305             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index13])))) /* ?{} */);
     375            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index13]) /* ?{} */);
    306376        }
    307377
     
    318388        signed int _index14 = 0;
    319389        for (;(_index14<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index14))) {
    320             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[_index14])))) /* ?{} */);
     390            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[_index14]) /* ?{} */);
    321391        }
    322392
     
    326396        signed int _index15 = 0;
    327397        for (;(_index15<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index15))) {
    328             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index15])))) /* ?{} */);
     398            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index15]) /* ?{} */);
    329399        }
    330400
     
    341411        signed int _index16 = 0;
    342412        for (;(_index16<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index16))) {
    343             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[_index16])))) /* ?{} */);
     413            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[_index16]) /* ?{} */);
    344414        }
    345415
     
    349419        signed int _index17 = 0;
    350420        for (;(_index17<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index17))) {
    351             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index17])))) /* ?{} */);
     421            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index17]) /* ?{} */);
    352422        }
    353423
     
    364434        signed int _index18 = 0;
    365435        for (;(_index18<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index18))) {
    366             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[_index18])))=__separator__A0c_1[_index18]) /* ?{} */);
     436            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[_index18]=__separator__A0c_1[_index18]) /* ?{} */);
    367437        }
    368438
     
    372442        signed int _index19 = 0;
    373443        for (;(_index19<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index19))) {
    374             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index19])))) /* ?{} */);
     444            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index19]) /* ?{} */);
    375445        }
    376446
     
    387457        signed int _index20 = 0;
    388458        for (;(_index20<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index20))) {
    389             ((void)((*((char *)(&(*___dst__R9sofstream_1).__separator__A0c_1[_index20])))=__separator__A0c_1[_index20]) /* ?{} */);
     459            ((void)((*___dst__R9sofstream_1).__separator__A0c_1[_index20]=__separator__A0c_1[_index20]) /* ?{} */);
    390460        }
    391461
     
    395465        signed int _index21 = 0;
    396466        for (;(_index21<((signed int )__sepSize__C13e__anonymous0_1));((void)(++_index21))) {
    397             ((void)((*((char *)(&(*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index21])))=__tupleSeparator__A0c_1[_index21]) /* ?{} */);
    398         }
    399 
    400     }
    401 
    402 }
    403 _Bool __sepPrt__Fb_R9sofstream__1(struct ofstream *__anonymous_object1351);
    404 void __sepReset__F_R9sofstream__1(struct ofstream *__anonymous_object1352);
    405 void __sepReset__F_R9sofstreamb__1(struct ofstream *__anonymous_object1353, _Bool __anonymous_object1354);
    406 const char *__sepGetCur__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1355);
    407 void __sepSetCur__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1356, const char *__anonymous_object1357);
    408 _Bool __getNL__Fb_R9sofstream__1(struct ofstream *__anonymous_object1358);
    409 void __setNL__F_R9sofstreamb__1(struct ofstream *__anonymous_object1359, _Bool __anonymous_object1360);
    410 void __sepOn__F_R9sofstream__1(struct ofstream *__anonymous_object1361);
    411 void __sepOff__F_R9sofstream__1(struct ofstream *__anonymous_object1362);
    412 _Bool __sepDisable__Fb_R9sofstream__1(struct ofstream *__anonymous_object1363);
    413 _Bool __sepEnable__Fb_R9sofstream__1(struct ofstream *__anonymous_object1364);
    414 const char *__sepGet__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1365);
    415 void __sepSet__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1366, const char *__anonymous_object1367);
    416 const char *__sepGetTuple__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1368);
    417 void __sepSetTuple__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1369, const char *__anonymous_object1370);
    418 signed int __fail__Fi_R9sofstream__1(struct ofstream *__anonymous_object1371);
    419 signed int __flush__Fi_R9sofstream__1(struct ofstream *__anonymous_object1372);
    420 void __open__F_R9sofstreamPCcPCc__1(struct ofstream *__anonymous_object1373, const char *__name__PCc_1, const char *__mode__PCc_1);
    421 void __open__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1374, const char *__name__PCc_1);
    422 void __close__F_R9sofstream__1(struct ofstream *__anonymous_object1375);
    423 struct ofstream *__write__FR9sofstream_R9sofstreamPCcUl__1(struct ofstream *__anonymous_object1376, const char *__data__PCc_1, unsigned long int __size__Ul_1);
    424 signed int __fmt__Fi_R9sofstreamPCc__1(struct ofstream *__anonymous_object1377, const char *__fmt__PCc_1, ...);
     467            ((void)((*___dst__R9sofstream_1).__tupleSeparator__A0c_1[_index21]=__tupleSeparator__A0c_1[_index21]) /* ?{} */);
     468        }
     469
     470    }
     471
     472}
     473_Bool __sepPrt__Fb_R9sofstream__1(struct ofstream *__anonymous_object1405);
     474void __sepReset__F_R9sofstream__1(struct ofstream *__anonymous_object1406);
     475void __sepReset__F_R9sofstreamb__1(struct ofstream *__anonymous_object1407, _Bool __anonymous_object1408);
     476const char *__sepGetCur__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1409);
     477void __sepSetCur__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1410, const char *__anonymous_object1411);
     478_Bool __getNL__Fb_R9sofstream__1(struct ofstream *__anonymous_object1412);
     479void __setNL__F_R9sofstreamb__1(struct ofstream *__anonymous_object1413, _Bool __anonymous_object1414);
     480void __sepOn__F_R9sofstream__1(struct ofstream *__anonymous_object1415);
     481void __sepOff__F_R9sofstream__1(struct ofstream *__anonymous_object1416);
     482_Bool __sepDisable__Fb_R9sofstream__1(struct ofstream *__anonymous_object1417);
     483_Bool __sepEnable__Fb_R9sofstream__1(struct ofstream *__anonymous_object1418);
     484const char *__sepGet__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1419);
     485void __sepSet__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1420, const char *__anonymous_object1421);
     486const char *__sepGetTuple__FPCc_R9sofstream__1(struct ofstream *__anonymous_object1422);
     487void __sepSetTuple__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1423, const char *__anonymous_object1424);
     488signed int __fail__Fi_R9sofstream__1(struct ofstream *__anonymous_object1425);
     489signed int __flush__Fi_R9sofstream__1(struct ofstream *__anonymous_object1426);
     490void __open__F_R9sofstreamPCcPCc__1(struct ofstream *__anonymous_object1427, const char *__name__PCc_1, const char *__mode__PCc_1);
     491void __open__F_R9sofstreamPCc__1(struct ofstream *__anonymous_object1428, const char *__name__PCc_1);
     492void __close__F_R9sofstream__1(struct ofstream *__anonymous_object1429);
     493struct ofstream *__write__FR9sofstream_R9sofstreamPCcUl__1(struct ofstream *__anonymous_object1430, const char *__data__PCc_1, unsigned long int __size__Ul_1);
     494signed int __fmt__Fi_R9sofstreamPCc__1(struct ofstream *__anonymous_object1431, const char *__fmt__PCc_1, ...);
    425495void ___constructor__F_R9sofstream__1(struct ofstream *__os__R9sofstream_1);
    426496void ___constructor__F_R9sofstreamPCcPCc__1(struct ofstream *__os__R9sofstream_1, const char *__name__PCc_1, const char *__mode__PCc_1);
     
    461531struct ifstream *__read__FR9sifstream_R9sifstreamPcUl__1(struct ifstream *__is__R9sifstream_1, char *__data__Pc_1, unsigned long int __size__Ul_1);
    462532struct ifstream *__ungetc__FR9sifstream_R9sifstreamc__1(struct ifstream *__is__R9sifstream_1, char __c__c_1);
    463 signed int __fmt__Fi_R9sifstreamPCc__1(struct ifstream *__anonymous_object1378, const char *__fmt__PCc_1, ...);
     533signed int __fmt__Fi_R9sifstreamPCc__1(struct ifstream *__anonymous_object1432, const char *__fmt__PCc_1, ...);
    464534void ___constructor__F_R9sifstream__1(struct ifstream *__is__R9sifstream_1);
    465535void ___constructor__F_R9sifstreamPCcPCc__1(struct ifstream *__is__R9sifstream_1, const char *__name__PCc_1, const char *__mode__PCc_1);
     
    471541    struct ofstream *_tmp_cp_ret4;
    472542    __attribute__ ((unused)) struct ofstream *_thunk0(struct ofstream *_p0){
    473         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1379))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1380))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1381, _Bool __anonymous_object1382))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1383))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1384, const char *__anonymous_object1385))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1386))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1387, _Bool __anonymous_object1388))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1389))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1390))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1391))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1392))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1393))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1394, const char *__anonymous_object1395))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1396))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1397, const char *__anonymous_object1398))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1399))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1400))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1401, const char *__anonymous_object1402, unsigned long int __anonymous_object1403))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1404, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    474     }
    475     ((void)(((void)(_tmp_cp_ret4=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1405))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1406))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1407, _Bool __anonymous_object1408))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1409))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1410, const char *__anonymous_object1411))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1412))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1413, _Bool __anonymous_object1414))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1415))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1416))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1417))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1418))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1419))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1420, const char *__anonymous_object1421))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1422))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1423, const char *__anonymous_object1424))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1425))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1426))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1427, const char *__anonymous_object1428, unsigned long int __anonymous_object1429))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1430, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret3=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0c__1(((_Bool (*)(void *__anonymous_object1431))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1432))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1433, _Bool __anonymous_object1434))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1435))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1436, const char *__anonymous_object1437))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1438))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1439, _Bool __anonymous_object1440))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1441))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1442))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1443))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1444))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1445))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1446, const char *__anonymous_object1447))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1448))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1449, const char *__anonymous_object1450))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1451))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1452))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1453, const char *__anonymous_object1454, unsigned long int __anonymous_object1455))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1456, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret2=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1457))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1458))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1459, _Bool __anonymous_object1460))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1461))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1462, const char *__anonymous_object1463))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1464))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1465, _Bool __anonymous_object1466))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1467))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1468))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1469))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1470))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1471))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1472, const char *__anonymous_object1473))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1474))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1475, const char *__anonymous_object1476))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1477))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1478))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1479, const char *__anonymous_object1480, unsigned long int __anonymous_object1481))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1482, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "char ")))) , _tmp_cp_ret2)), __v__c_1)))) , _tmp_cp_ret3)), ((void *(*)(void *__anonymous_object1483))(&_thunk0)))))) , _tmp_cp_ret4));
     543        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1433))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1434))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1435, _Bool __anonymous_object1436))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1437))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1438, const char *__anonymous_object1439))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1440))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1441, _Bool __anonymous_object1442))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1443))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1444))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1445))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1446))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1447))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1448, const char *__anonymous_object1449))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1450))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1451, const char *__anonymous_object1452))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1453))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1454))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1455, const char *__anonymous_object1456, unsigned long int __anonymous_object1457))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1458, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     544    }
     545    ((void)(((void)(_tmp_cp_ret4=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1459))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1460))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1461, _Bool __anonymous_object1462))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1463))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1464, const char *__anonymous_object1465))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1466))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1467, _Bool __anonymous_object1468))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1469))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1470))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1471))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1472))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1473))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1474, const char *__anonymous_object1475))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1476))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1477, const char *__anonymous_object1478))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1479))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1480))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1481, const char *__anonymous_object1482, unsigned long int __anonymous_object1483))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1484, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret3=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0c__1(((_Bool (*)(void *__anonymous_object1485))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1486))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1487, _Bool __anonymous_object1488))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1489))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1490, const char *__anonymous_object1491))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1492))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1493, _Bool __anonymous_object1494))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1495))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1496))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1497))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1498))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1499))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1500, const char *__anonymous_object1501))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1502))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1503, const char *__anonymous_object1504))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1505))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1506))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1507, const char *__anonymous_object1508, unsigned long int __anonymous_object1509))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1510, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret2=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1511))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1512))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1513, _Bool __anonymous_object1514))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1515))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1516, const char *__anonymous_object1517))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1518))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1519, _Bool __anonymous_object1520))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1521))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1522))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1523))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1524))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1525))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1526, const char *__anonymous_object1527))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1528))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1529, const char *__anonymous_object1530))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1531))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1532))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1533, const char *__anonymous_object1534, unsigned long int __anonymous_object1535))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1536, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "char "))) , _tmp_cp_ret2)), __v__c_1))) , _tmp_cp_ret3)), ((void *(*)(void *__anonymous_object1537))(&_thunk0))))) , _tmp_cp_ret4));
    476546}
    477547void __f__F_Sc__1(signed char __v__Sc_1){
     
    480550    struct ofstream *_tmp_cp_ret7;
    481551    __attribute__ ((unused)) struct ofstream *_thunk1(struct ofstream *_p0){
    482         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1484))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1485))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1486, _Bool __anonymous_object1487))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1488))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1489, const char *__anonymous_object1490))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1491))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1492, _Bool __anonymous_object1493))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1494))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1495))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1496))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1497))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1498))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1499, const char *__anonymous_object1500))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1501))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1502, const char *__anonymous_object1503))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1504))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1505))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1506, const char *__anonymous_object1507, unsigned long int __anonymous_object1508))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1509, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    483     }
    484     ((void)(((void)(_tmp_cp_ret7=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1510))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1511))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1512, _Bool __anonymous_object1513))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1514))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1515, const char *__anonymous_object1516))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1517))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1518, _Bool __anonymous_object1519))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1520))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1521))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1522))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1523))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1524))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1525, const char *__anonymous_object1526))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1527))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1528, const char *__anonymous_object1529))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1530))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1531))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1532, const char *__anonymous_object1533, unsigned long int __anonymous_object1534))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1535, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret6=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Sc__1(((_Bool (*)(void *__anonymous_object1536))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1537))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1538, _Bool __anonymous_object1539))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1540))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1541, const char *__anonymous_object1542))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1543))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1544, _Bool __anonymous_object1545))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1546))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1547))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1548))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1549))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1550))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1551, const char *__anonymous_object1552))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1553))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1554, const char *__anonymous_object1555))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1556))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1557))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1558, const char *__anonymous_object1559, unsigned long int __anonymous_object1560))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1561, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret5=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1562))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1563))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1564, _Bool __anonymous_object1565))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1566))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1567, const char *__anonymous_object1568))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1569))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1570, _Bool __anonymous_object1571))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1572))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1573))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1574))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1575))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1576))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1577, const char *__anonymous_object1578))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1579))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1580, const char *__anonymous_object1581))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1582))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1583))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1584, const char *__anonymous_object1585, unsigned long int __anonymous_object1586))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1587, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "signed char ")))) , _tmp_cp_ret5)), __v__Sc_1)))) , _tmp_cp_ret6)), ((void *(*)(void *__anonymous_object1588))(&_thunk1)))))) , _tmp_cp_ret7));
     552        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1538))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1539))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1540, _Bool __anonymous_object1541))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1542))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1543, const char *__anonymous_object1544))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1545))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1546, _Bool __anonymous_object1547))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1548))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1549))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1550))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1551))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1552))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1553, const char *__anonymous_object1554))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1555))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1556, const char *__anonymous_object1557))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1558))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1559))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1560, const char *__anonymous_object1561, unsigned long int __anonymous_object1562))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1563, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     553    }
     554    ((void)(((void)(_tmp_cp_ret7=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1564))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1565))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1566, _Bool __anonymous_object1567))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1568))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1569, const char *__anonymous_object1570))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1571))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1572, _Bool __anonymous_object1573))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1574))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1575))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1576))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1577))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1578))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1579, const char *__anonymous_object1580))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1581))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1582, const char *__anonymous_object1583))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1584))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1585))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1586, const char *__anonymous_object1587, unsigned long int __anonymous_object1588))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1589, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret6=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Sc__1(((_Bool (*)(void *__anonymous_object1590))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1591))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1592, _Bool __anonymous_object1593))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1594))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1595, const char *__anonymous_object1596))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1597))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1598, _Bool __anonymous_object1599))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1600))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1601))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1602))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1603))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1604))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1605, const char *__anonymous_object1606))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1607))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1608, const char *__anonymous_object1609))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1610))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1611))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1612, const char *__anonymous_object1613, unsigned long int __anonymous_object1614))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1615, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret5=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1616))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1617))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1618, _Bool __anonymous_object1619))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1620))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1621, const char *__anonymous_object1622))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1623))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1624, _Bool __anonymous_object1625))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1626))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1627))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1628))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1629))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1630))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1631, const char *__anonymous_object1632))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1633))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1634, const char *__anonymous_object1635))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1636))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1637))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1638, const char *__anonymous_object1639, unsigned long int __anonymous_object1640))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1641, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "signed char "))) , _tmp_cp_ret5)), __v__Sc_1))) , _tmp_cp_ret6)), ((void *(*)(void *__anonymous_object1642))(&_thunk1))))) , _tmp_cp_ret7));
    485555}
    486556void __f__F_Uc__1(unsigned char __v__Uc_1){
     
    489559    struct ofstream *_tmp_cp_ret10;
    490560    __attribute__ ((unused)) struct ofstream *_thunk2(struct ofstream *_p0){
    491         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1589))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1590))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1591, _Bool __anonymous_object1592))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1593))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1594, const char *__anonymous_object1595))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1596))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1597, _Bool __anonymous_object1598))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1599))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1600))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1601))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1602))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1603))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1604, const char *__anonymous_object1605))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1606))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1607, const char *__anonymous_object1608))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1609))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1610))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1611, const char *__anonymous_object1612, unsigned long int __anonymous_object1613))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1614, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    492     }
    493     ((void)(((void)(_tmp_cp_ret10=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1615))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1616))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1617, _Bool __anonymous_object1618))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1619))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1620, const char *__anonymous_object1621))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1622))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1623, _Bool __anonymous_object1624))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1625))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1626))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1627))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1628))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1629))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1630, const char *__anonymous_object1631))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1632))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1633, const char *__anonymous_object1634))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1635))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1636))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1637, const char *__anonymous_object1638, unsigned long int __anonymous_object1639))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1640, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret9=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Uc__1(((_Bool (*)(void *__anonymous_object1641))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1642))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1643, _Bool __anonymous_object1644))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1645))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1646, const char *__anonymous_object1647))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1648))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1649, _Bool __anonymous_object1650))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1651))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1652))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1653))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1654))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1655))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1656, const char *__anonymous_object1657))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1658))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1659, const char *__anonymous_object1660))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1661))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1662))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1663, const char *__anonymous_object1664, unsigned long int __anonymous_object1665))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1666, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret8=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1667))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1668))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1669, _Bool __anonymous_object1670))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1671))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1672, const char *__anonymous_object1673))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1674))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1675, _Bool __anonymous_object1676))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1677))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1678))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1679))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1680))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1681))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1682, const char *__anonymous_object1683))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1684))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1685, const char *__anonymous_object1686))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1687))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1688))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1689, const char *__anonymous_object1690, unsigned long int __anonymous_object1691))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1692, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "unsigned char ")))) , _tmp_cp_ret8)), __v__Uc_1)))) , _tmp_cp_ret9)), ((void *(*)(void *__anonymous_object1693))(&_thunk2)))))) , _tmp_cp_ret10));
     561        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1643))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1644))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1645, _Bool __anonymous_object1646))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1647))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1648, const char *__anonymous_object1649))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1650))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1651, _Bool __anonymous_object1652))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1653))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1654))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1655))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1656))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1657))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1658, const char *__anonymous_object1659))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1660))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1661, const char *__anonymous_object1662))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1663))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1664))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1665, const char *__anonymous_object1666, unsigned long int __anonymous_object1667))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1668, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     562    }
     563    ((void)(((void)(_tmp_cp_ret10=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1669))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1670))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1671, _Bool __anonymous_object1672))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1673))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1674, const char *__anonymous_object1675))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1676))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1677, _Bool __anonymous_object1678))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1679))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1680))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1681))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1682))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1683))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1684, const char *__anonymous_object1685))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1686))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1687, const char *__anonymous_object1688))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1689))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1690))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1691, const char *__anonymous_object1692, unsigned long int __anonymous_object1693))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1694, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret9=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Uc__1(((_Bool (*)(void *__anonymous_object1695))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1696))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1697, _Bool __anonymous_object1698))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1699))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1700, const char *__anonymous_object1701))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1702))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1703, _Bool __anonymous_object1704))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1705))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1706))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1707))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1708))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1709))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1710, const char *__anonymous_object1711))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1712))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1713, const char *__anonymous_object1714))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1715))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1716))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1717, const char *__anonymous_object1718, unsigned long int __anonymous_object1719))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1720, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret8=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1721))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1722))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1723, _Bool __anonymous_object1724))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1725))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1726, const char *__anonymous_object1727))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1728))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1729, _Bool __anonymous_object1730))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1731))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1732))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1733))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1734))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1735))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1736, const char *__anonymous_object1737))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1738))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1739, const char *__anonymous_object1740))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1741))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1742))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1743, const char *__anonymous_object1744, unsigned long int __anonymous_object1745))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1746, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "unsigned char "))) , _tmp_cp_ret8)), __v__Uc_1))) , _tmp_cp_ret9)), ((void *(*)(void *__anonymous_object1747))(&_thunk2))))) , _tmp_cp_ret10));
    494564}
    495565void __f__F_s__1(signed short int __v__s_1){
     
    498568    struct ofstream *_tmp_cp_ret13;
    499569    __attribute__ ((unused)) struct ofstream *_thunk3(struct ofstream *_p0){
    500         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1694))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1695))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1696, _Bool __anonymous_object1697))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1698))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1699, const char *__anonymous_object1700))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1701))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1702, _Bool __anonymous_object1703))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1704))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1705))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1706))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1707))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1708))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1709, const char *__anonymous_object1710))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1711))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1712, const char *__anonymous_object1713))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1714))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1715))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1716, const char *__anonymous_object1717, unsigned long int __anonymous_object1718))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1719, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    501     }
    502     ((void)(((void)(_tmp_cp_ret13=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1720))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1721))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1722, _Bool __anonymous_object1723))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1724))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1725, const char *__anonymous_object1726))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1727))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1728, _Bool __anonymous_object1729))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1730))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1731))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1732))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1733))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1734))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1735, const char *__anonymous_object1736))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1737))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1738, const char *__anonymous_object1739))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1740))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1741))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1742, const char *__anonymous_object1743, unsigned long int __anonymous_object1744))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1745, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret12=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0s__1(((_Bool (*)(void *__anonymous_object1746))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1747))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1748, _Bool __anonymous_object1749))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1750))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1751, const char *__anonymous_object1752))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1753))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1754, _Bool __anonymous_object1755))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1756))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1757))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1758))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1759))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1760))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1761, const char *__anonymous_object1762))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1763))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1764, const char *__anonymous_object1765))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1766))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1767))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1768, const char *__anonymous_object1769, unsigned long int __anonymous_object1770))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1771, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret11=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1772))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1773))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1774, _Bool __anonymous_object1775))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1776))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1777, const char *__anonymous_object1778))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1779))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1780, _Bool __anonymous_object1781))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1782))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1783))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1784))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1785))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1786))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1787, const char *__anonymous_object1788))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1789))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1790, const char *__anonymous_object1791))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1792))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1793))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1794, const char *__anonymous_object1795, unsigned long int __anonymous_object1796))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1797, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "signed short int")))) , _tmp_cp_ret11)), __v__s_1)))) , _tmp_cp_ret12)), ((void *(*)(void *__anonymous_object1798))(&_thunk3)))))) , _tmp_cp_ret13));
     570        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1748))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1749))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1750, _Bool __anonymous_object1751))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1752))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1753, const char *__anonymous_object1754))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1755))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1756, _Bool __anonymous_object1757))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1758))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1759))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1760))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1761))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1762))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1763, const char *__anonymous_object1764))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1765))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1766, const char *__anonymous_object1767))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1768))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1769))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1770, const char *__anonymous_object1771, unsigned long int __anonymous_object1772))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1773, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     571    }
     572    ((void)(((void)(_tmp_cp_ret13=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1774))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1775))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1776, _Bool __anonymous_object1777))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1778))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1779, const char *__anonymous_object1780))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1781))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1782, _Bool __anonymous_object1783))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1784))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1785))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1786))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1787))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1788))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1789, const char *__anonymous_object1790))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1791))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1792, const char *__anonymous_object1793))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1794))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1795))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1796, const char *__anonymous_object1797, unsigned long int __anonymous_object1798))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1799, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret12=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0s__1(((_Bool (*)(void *__anonymous_object1800))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1801))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1802, _Bool __anonymous_object1803))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1804))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1805, const char *__anonymous_object1806))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1807))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1808, _Bool __anonymous_object1809))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1810))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1811))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1812))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1813))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1814))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1815, const char *__anonymous_object1816))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1817))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1818, const char *__anonymous_object1819))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1820))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1821))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1822, const char *__anonymous_object1823, unsigned long int __anonymous_object1824))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1825, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret11=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1826))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1827))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1828, _Bool __anonymous_object1829))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1830))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1831, const char *__anonymous_object1832))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1833))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1834, _Bool __anonymous_object1835))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1836))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1837))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1838))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1839))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1840))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1841, const char *__anonymous_object1842))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1843))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1844, const char *__anonymous_object1845))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1846))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1847))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1848, const char *__anonymous_object1849, unsigned long int __anonymous_object1850))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1851, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "signed short int"))) , _tmp_cp_ret11)), __v__s_1))) , _tmp_cp_ret12)), ((void *(*)(void *__anonymous_object1852))(&_thunk3))))) , _tmp_cp_ret13));
    503573}
    504574void __f__F_Us__1(unsigned short int __v__Us_1){
     
    507577    struct ofstream *_tmp_cp_ret16;
    508578    __attribute__ ((unused)) struct ofstream *_thunk4(struct ofstream *_p0){
    509         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1799))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1800))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1801, _Bool __anonymous_object1802))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1803))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1804, const char *__anonymous_object1805))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1806))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1807, _Bool __anonymous_object1808))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1809))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1810))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1811))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1812))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1813))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1814, const char *__anonymous_object1815))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1816))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1817, const char *__anonymous_object1818))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1819))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1820))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1821, const char *__anonymous_object1822, unsigned long int __anonymous_object1823))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1824, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    510     }
    511     ((void)(((void)(_tmp_cp_ret16=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1825))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1826))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1827, _Bool __anonymous_object1828))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1829))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1830, const char *__anonymous_object1831))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1832))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1833, _Bool __anonymous_object1834))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1835))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1836))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1837))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1838))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1839))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1840, const char *__anonymous_object1841))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1842))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1843, const char *__anonymous_object1844))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1845))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1846))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1847, const char *__anonymous_object1848, unsigned long int __anonymous_object1849))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1850, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret15=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Us__1(((_Bool (*)(void *__anonymous_object1851))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1852))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1853, _Bool __anonymous_object1854))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1855))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1856, const char *__anonymous_object1857))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1858))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1859, _Bool __anonymous_object1860))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1861))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1862))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1863))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1864))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1865))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1866, const char *__anonymous_object1867))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1868))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1869, const char *__anonymous_object1870))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1871))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1872))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1873, const char *__anonymous_object1874, unsigned long int __anonymous_object1875))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1876, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret14=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1877))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1878))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1879, _Bool __anonymous_object1880))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1881))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1882, const char *__anonymous_object1883))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1884))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1885, _Bool __anonymous_object1886))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1887))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1888))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1889))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1890))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1891))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1892, const char *__anonymous_object1893))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1894))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1895, const char *__anonymous_object1896))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1897))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1898))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1899, const char *__anonymous_object1900, unsigned long int __anonymous_object1901))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1902, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "unsigned short int")))) , _tmp_cp_ret14)), __v__Us_1)))) , _tmp_cp_ret15)), ((void *(*)(void *__anonymous_object1903))(&_thunk4)))))) , _tmp_cp_ret16));
     579        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1853))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1854))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1855, _Bool __anonymous_object1856))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1857))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1858, const char *__anonymous_object1859))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1860))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1861, _Bool __anonymous_object1862))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1863))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1864))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1865))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1866))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1867))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1868, const char *__anonymous_object1869))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1870))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1871, const char *__anonymous_object1872))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1873))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1874))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1875, const char *__anonymous_object1876, unsigned long int __anonymous_object1877))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1878, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     580    }
     581    ((void)(((void)(_tmp_cp_ret16=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1879))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1880))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1881, _Bool __anonymous_object1882))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1883))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1884, const char *__anonymous_object1885))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1886))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1887, _Bool __anonymous_object1888))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1889))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1890))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1891))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1892))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1893))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1894, const char *__anonymous_object1895))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1896))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1897, const char *__anonymous_object1898))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1899))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1900))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1901, const char *__anonymous_object1902, unsigned long int __anonymous_object1903))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1904, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret15=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Us__1(((_Bool (*)(void *__anonymous_object1905))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1906))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1907, _Bool __anonymous_object1908))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1909))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1910, const char *__anonymous_object1911))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1912))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1913, _Bool __anonymous_object1914))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1915))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1916))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1917))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1918))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1919))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1920, const char *__anonymous_object1921))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1922))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1923, const char *__anonymous_object1924))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1925))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1926))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1927, const char *__anonymous_object1928, unsigned long int __anonymous_object1929))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1930, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret14=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1931))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1932))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1933, _Bool __anonymous_object1934))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1935))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1936, const char *__anonymous_object1937))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1938))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1939, _Bool __anonymous_object1940))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1941))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1942))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1943))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1944))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1945))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1946, const char *__anonymous_object1947))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1948))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1949, const char *__anonymous_object1950))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1951))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1952))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1953, const char *__anonymous_object1954, unsigned long int __anonymous_object1955))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1956, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "unsigned short int"))) , _tmp_cp_ret14)), __v__Us_1))) , _tmp_cp_ret15)), ((void *(*)(void *__anonymous_object1957))(&_thunk4))))) , _tmp_cp_ret16));
    512582}
    513583void __f__F_Ui__1(unsigned int __v__Ui_1){
     
    516586    struct ofstream *_tmp_cp_ret19;
    517587    __attribute__ ((unused)) struct ofstream *_thunk5(struct ofstream *_p0){
    518         return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1904))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1905))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1906, _Bool __anonymous_object1907))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1908))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1909, const char *__anonymous_object1910))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1911))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1912, _Bool __anonymous_object1913))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1914))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1915))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1916))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1917))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1918))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1919, const char *__anonymous_object1920))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1921))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1922, const char *__anonymous_object1923))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1924))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1925))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1926, const char *__anonymous_object1927, unsigned long int __anonymous_object1928))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1929, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
    519     }
    520     ((void)(((void)(_tmp_cp_ret19=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1930))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1931))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1932, _Bool __anonymous_object1933))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1934))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1935, const char *__anonymous_object1936))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1937))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1938, _Bool __anonymous_object1939))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1940))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1941))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1942))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1943))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1944))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1945, const char *__anonymous_object1946))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1947))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1948, const char *__anonymous_object1949))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1950))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1951))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1952, const char *__anonymous_object1953, unsigned long int __anonymous_object1954))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1955, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret18=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Ui__1(((_Bool (*)(void *__anonymous_object1956))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1957))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1958, _Bool __anonymous_object1959))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1960))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1961, const char *__anonymous_object1962))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1963))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1964, _Bool __anonymous_object1965))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1966))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1967))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1968))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1969))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1970))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1971, const char *__anonymous_object1972))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1973))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1974, const char *__anonymous_object1975))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1976))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1977))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1978, const char *__anonymous_object1979, unsigned long int __anonymous_object1980))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1981, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret17=((struct ofstream *)___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object1982))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1983))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1984, _Bool __anonymous_object1985))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1986))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1987, const char *__anonymous_object1988))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1989))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1990, _Bool __anonymous_object1991))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1992))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1993))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1994))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1995))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1996))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1997, const char *__anonymous_object1998))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1999))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2000, const char *__anonymous_object2001))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object2002))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object2003))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object2004, const char *__anonymous_object2005, unsigned long int __anonymous_object2006))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object2007, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "size_t")))) , _tmp_cp_ret17)), __v__Ui_1)))) , _tmp_cp_ret18)), ((void *(*)(void *__anonymous_object2008))(&_thunk5)))))) , _tmp_cp_ret19));
     588        return __endl__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0__1(((_Bool (*)(void *__anonymous_object1958))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1959))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1960, _Bool __anonymous_object1961))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1962))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1963, const char *__anonymous_object1964))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1965))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1966, _Bool __anonymous_object1967))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1968))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1969))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1970))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1971))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1972))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1973, const char *__anonymous_object1974))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object1975))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1976, const char *__anonymous_object1977))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object1978))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object1979))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object1980, const char *__anonymous_object1981, unsigned long int __anonymous_object1982))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object1983, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)_p0));
     589    }
     590    ((void)(((void)(_tmp_cp_ret19=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PFRd0_Rd0___1(((_Bool (*)(void *__anonymous_object1984))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1985))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object1986, _Bool __anonymous_object1987))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object1988))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1989, const char *__anonymous_object1990))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object1991))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object1992, _Bool __anonymous_object1993))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object1994))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object1995))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1996))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object1997))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object1998))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object1999, const char *__anonymous_object2000))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object2001))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2002, const char *__anonymous_object2003))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object2004))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object2005))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object2006, const char *__anonymous_object2007, unsigned long int __anonymous_object2008))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object2009, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret18=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0Ui__1(((_Bool (*)(void *__anonymous_object2010))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object2011))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object2012, _Bool __anonymous_object2013))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object2014))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2015, const char *__anonymous_object2016))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object2017))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object2018, _Bool __anonymous_object2019))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object2020))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object2021))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object2022))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object2023))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object2024))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2025, const char *__anonymous_object2026))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object2027))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2028, const char *__anonymous_object2029))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object2030))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object2031))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object2032, const char *__anonymous_object2033, unsigned long int __anonymous_object2034))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object2035, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)(((void)(_tmp_cp_ret17=___operator_bitor__A0_1_0_0___sepPrt__PFb_Rd0___sepReset__PF_Rd0___sepReset__PF_Rd0b___sepGetCur__PFPCc_Rd0___sepSetCur__PF_Rd0PCc___getNL__PFb_Rd0___setNL__PF_Rd0b___sepOn__PF_Rd0___sepOff__PF_Rd0___sepDisable__PFb_Rd0___sepEnable__PFb_Rd0___sepGet__PFPCc_Rd0___sepSet__PF_Rd0PCc___sepGetTuple__PFPCc_Rd0___sepSetTuple__PF_Rd0PCc___fail__PFi_Rd0___flush__PFi_Rd0___open__PF_Rd0PCcPCc___close__PF_Rd0___write__PFRd0_Rd0PCcUl___fmt__PFi_Rd0PCc__FRd0_Rd0PCc__1(((_Bool (*)(void *__anonymous_object2036))__sepPrt__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object2037))__sepReset__F_R9sofstream__1), ((void (*)(void *__anonymous_object2038, _Bool __anonymous_object2039))__sepReset__F_R9sofstreamb__1), ((const char *(*)(void *__anonymous_object2040))__sepGetCur__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2041, const char *__anonymous_object2042))__sepSetCur__F_R9sofstreamPCc__1), ((_Bool (*)(void *__anonymous_object2043))__getNL__Fb_R9sofstream__1), ((void (*)(void *__anonymous_object2044, _Bool __anonymous_object2045))__setNL__F_R9sofstreamb__1), ((void (*)(void *__anonymous_object2046))__sepOn__F_R9sofstream__1), ((void (*)(void *__anonymous_object2047))__sepOff__F_R9sofstream__1), ((_Bool (*)(void *__anonymous_object2048))__sepDisable__Fb_R9sofstream__1), ((_Bool (*)(void *__anonymous_object2049))__sepEnable__Fb_R9sofstream__1), ((const char *(*)(void *__anonymous_object2050))__sepGet__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2051, const char *__anonymous_object2052))__sepSet__F_R9sofstreamPCc__1), ((const char *(*)(void *__anonymous_object2053))__sepGetTuple__FPCc_R9sofstream__1), ((void (*)(void *__anonymous_object2054, const char *__anonymous_object2055))__sepSetTuple__F_R9sofstreamPCc__1), ((signed int (*)(void *__anonymous_object2056))__fail__Fi_R9sofstream__1), ((signed int (*)(void *__anonymous_object2057))__flush__Fi_R9sofstream__1), ((void (*)(void *__os__R7tostype_1, const char *__name__PCc_1, const char *__mode__PCc_1))__open__F_R9sofstreamPCcPCc__1), ((void (*)(void *__os__R7tostype_1))__close__F_R9sofstream__1), ((void *(*)(void *__anonymous_object2058, const char *__anonymous_object2059, unsigned long int __anonymous_object2060))__write__FR9sofstream_R9sofstreamPCcUl__1), ((signed int (*)(void *__anonymous_object2061, const char *__fmt__PCc_1, ...))__fmt__Fi_R9sofstreamPCc__1), ((void *)__sout__R9sofstream_1), "size_t"))) , _tmp_cp_ret17)), __v__Ui_1))) , _tmp_cp_ret18)), ((void *(*)(void *__anonymous_object2062))(&_thunk5))))) , _tmp_cp_ret19));
    521591}
    522592signed int __main__Fi___1(){
  • src/tests/.expect/references.txt

    r2efe4b8 r1cdfa82  
    4413 1 12
    5514 14
     6x = 6 ; x2 = 789
     7x = 6 ; x2 = 999
     8x = 12345 ; x2 = 999
     9x = 22222 ; x2 = 999
    610Default constructing a Y
    711Copy constructing a Y
     
    2832Destructing a Y
    2933Destructing a Y
     343 3
     353
     363
     373 9 { 1, 7 }, [1, 2, 3]
    3038Destructing a Y
    3139Destructing a Y
  • src/tests/Makefile.am

    r2efe4b8 r1cdfa82  
    110110        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
    111111
     112fallthrough-ERROR: fallthrough.c @CFA_BINDIR@/@CFA_NAME@
     113        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
     114
    112115# Constructor/destructor tests
    113116raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
  • src/tests/Makefile.in

    r2efe4b8 r1cdfa82  
    787787        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
    788788
     789fallthrough-ERROR: fallthrough.c @CFA_BINDIR@/@CFA_NAME@
     790        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
     791
    789792# Constructor/destructor tests
    790793raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
  • src/tests/concurrent/.expect/preempt.txt

    r2efe4b8 r1cdfa82  
    44400
    55500
    6 600
    7 700
    8 800
    9 900
    10 1000
  • src/tests/concurrent/examples/datingService.c

    r2efe4b8 r1cdfa82  
    88// Created On       : Mon Oct 30 12:56:20 2017
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Tue Jan  2 12:19:01 2018
    11 // Update Count     : 22
     10// Last Modified On : Wed Mar 14 22:48:40 2018
     11// Update Count     : 23
    1212//
    1313
     
    8888int main() {
    8989        DatingService TheExchange;
    90         Girl *girls[NoOfPairs];
    91         Boy  *boys[NoOfPairs];
     90        Girl * girls[NoOfPairs];
     91        Boy  * boys[NoOfPairs];
    9292
    9393        srandom( /*getpid()*/ 103 );
  • src/tests/concurrent/preempt.c

    r2efe4b8 r1cdfa82  
    11#include <kernel>
    22#include <thread>
     3#include <time>
    34
    45#ifndef PREEMPTION_RATE
    5 #define PREEMPTION_RATE 10_000ul
     6#define PREEMPTION_RATE 10`ms
    67#endif
    78
    8 unsigned int default_preemption() {
     9Duration default_preemption() {
    910        return PREEMPTION_RATE;
    1011}
     12
     13#ifdef LONG_TEST
     14static const unsigned long N = 30_000ul;
     15#else
     16static const unsigned long N = 500ul;
     17#endif
    1118
    1219static volatile int counter = 0;
     
    2128
    2229void main(worker_t & this) {
    23         while(counter < 1000) {
     30        while(counter < N) {
    2431                if( (counter % 7) == this.value ) {
    2532                        int next = __atomic_add_fetch_4(&counter, 1, __ATOMIC_SEQ_CST);
  • src/tests/concurrent/signal/barge.c

    r2efe4b8 r1cdfa82  
    1616
    1717#ifndef PREEMPTION_RATE
    18 #define PREEMPTION_RATE 10_000ul
     18#define PREEMPTION_RATE 10`ms
    1919#endif
    2020
    21 unsigned int default_preemption() {
     21Duration default_preemption() {
    2222        return 0;
    2323}
  • src/tests/concurrent/signal/block.c

    r2efe4b8 r1cdfa82  
    1212#include <stdlib>
    1313#include <thread>
    14 
    15 #include <time.h>
     14#include <time>
    1615
    1716#ifdef LONG_TEST
     
    2221
    2322#ifndef PREEMPTION_RATE
    24 #define PREEMPTION_RATE 10_000ul
     23#define PREEMPTION_RATE 10`ms
    2524#endif
    2625
    27 unsigned int default_preemption() {
     26Duration default_preemption() {
    2827        return PREEMPTION_RATE;
    2928}
     
    5150//------------------------------------------------------------------------------
    5251void wait_op( global_data_t & mutex a, global_data_t & mutex b, unsigned i ) {
    53         wait( cond, (uintptr_t)this_thread );
     52    wait( cond, (uintptr_t)active_thread() );
    5453
    5554        yield( random( 10 ) );
     
    6059        }
    6160
    62         a.last_thread = b.last_thread = this_thread;
     61        a.last_thread = b.last_thread = active_thread();
    6362
    6463        yield( random( 10 ) );
     
    7675        yield( random( 10 ) );
    7776
    78         [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = this_thread;
     77        [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = active_thread();
    7978
    8079        if( !is_empty( cond ) ) {
     
    106105//------------------------------------------------------------------------------
    107106void barge_op( global_data_t & mutex a ) {
    108         a.last_thread = this_thread;
     107        a.last_thread = active_thread();
    109108}
    110109
  • src/tests/concurrent/signal/disjoint.c

    r2efe4b8 r1cdfa82  
    33#include <monitor>
    44#include <thread>
    5 
    6 #include <time.h>
     5#include <time>
    76
    87#ifdef LONG_TEST
     
    1312
    1413#ifndef PREEMPTION_RATE
    15 #define PREEMPTION_RATE 10_000ul
     14#define PREEMPTION_RATE 10`ms
    1615#endif
    1716
    18 unsigned int default_preemption() {
     17Duration default_preemption() {
    1918        return PREEMPTION_RATE;
    2019}
  • src/tests/concurrent/signal/wait.c

    r2efe4b8 r1cdfa82  
    1010#include <stdlib>
    1111#include <thread>
    12 
    13 #include <time.h>
     12#include <time>
    1413
    1514#ifdef LONG_TEST
     
    2019
    2120#ifndef PREEMPTION_RATE
    22 #define PREEMPTION_RATE 10_000ul
     21#define PREEMPTION_RATE 10`ms
    2322#endif
    2423
    25 unsigned int default_preemption() {
     24Duration default_preemption() {
    2625        return PREEMPTION_RATE;
    2726}
  • src/tests/concurrent/waitfor/simple.c

    r2efe4b8 r1cdfa82  
    1010
    1111#ifndef PREEMPTION_RATE
    12 #define PREEMPTION_RATE 10_000ul
     12#define PREEMPTION_RATE 10`ms
    1313#endif
    1414
    15 unsigned int default_preemption() {
     15Duration default_preemption() {
    1616        return PREEMPTION_RATE;
    1717}
  • src/tests/coroutine/fibonacci.c

    r2efe4b8 r1cdfa82  
    1010// Created On       : Thu Jun  8 07:29:37 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  5 22:27:54 2017
    13 // Update Count     : 14
     12// Last Modified On : Thu Mar 22 22:45:44 2018
     13// Update Count     : 15
    1414//
    1515
     
    2121void ?{}( Fibonacci & fib ) with( fib ) { fn = 0; }
    2222
     23// main automatically called on first resume
    2324void main( Fibonacci & fib ) with( fib ) {
    2425        int fn1, fn2;                                                                           // retained between resumes
    25 
    26         fn = 0; fn1 = fn;                                                                       // 1st case
     26        fn = 0;  fn1 = fn;                                                                      // 1st case
    2727        suspend();                                                                                      // restart last resume
    28 
    29         fn = 1; fn2 = fn1;  fn1 = fn;                                           // 2nd case
     28        fn = 1;  fn2 = fn1;  fn1 = fn;                                          // 2nd case
    3029        suspend();                                                                                      // restart last resume
    31 
    3230        for ( ;; ) {
    3331                fn = fn1 + fn2; fn2 = fn1;  fn1 = fn;                   // general case
  • src/tests/minmax.c

    r2efe4b8 r1cdfa82  
    77// minmax.c --
    88//
    9 // Author           : Richard C. Bilson
     9// Author           : Peter A. Buhr
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Feb 29 23:45:16 2016
    13 // Update Count     : 49
     12// Last Modified On : Tue Apr 10 17:29:09 2018
     13// Update Count     : 50
    1414//
    1515
  • src/tests/operators.c

    r2efe4b8 r1cdfa82  
    2727        a(b);
    2828        a + b;
    29         struct accumulator ?+?; // why not, eh?
    30         a + b;
    3129}
    3230
  • src/tests/preempt_longrun/create.c

    r2efe4b8 r1cdfa82  
    55
    66#ifndef PREEMPTION_RATE
    7 #define PREEMPTION_RATE 10_000ul
     7#define PREEMPTION_RATE 10`ms
    88#endif
    99
    10 unsigned int default_preemption() {
     10Duration default_preemption() {
    1111        return PREEMPTION_RATE;
    1212}
  • src/tests/preempt_longrun/enter.c

    r2efe4b8 r1cdfa82  
    66
    77#ifndef PREEMPTION_RATE
    8 #define PREEMPTION_RATE 10_000ul
     8#define PREEMPTION_RATE 10`ms
    99#endif
    1010
    11 unsigned int default_preemption() {
     11Duration default_preemption() {
    1212        return PREEMPTION_RATE;
    1313}
  • src/tests/preempt_longrun/enter3.c

    r2efe4b8 r1cdfa82  
    66
    77#ifndef PREEMPTION_RATE
    8 #define PREEMPTION_RATE 10_000ul
     8#define PREEMPTION_RATE 10`ms
    99#endif
    1010
    11 unsigned int default_preemption() {
     11Duration default_preemption() {
    1212        return PREEMPTION_RATE;
    1313}
  • src/tests/preempt_longrun/processor.c

    r2efe4b8 r1cdfa82  
    55
    66#ifndef PREEMPTION_RATE
    7 #define PREEMPTION_RATE 10_000ul
     7#define PREEMPTION_RATE 10`ms
    88#endif
    99
    10 unsigned int default_preemption() {
     10Duration default_preemption() {
    1111        return PREEMPTION_RATE;
    1212}
  • src/tests/preempt_longrun/stack.c

    r2efe4b8 r1cdfa82  
    55
    66#ifndef PREEMPTION_RATE
    7 #define PREEMPTION_RATE 10_000ul
     7#define PREEMPTION_RATE 10`ms
    88#endif
    99
    10 unsigned int default_preemption() {
     10Duration default_preemption() {
    1111        return PREEMPTION_RATE;
    1212}
  • src/tests/preempt_longrun/yield.c

    r2efe4b8 r1cdfa82  
    99
    1010#ifndef PREEMPTION_RATE
    11 #define PREEMPTION_RATE 10_000ul
     11#define PREEMPTION_RATE 10`ms
    1212#endif
    1313
    14 unsigned int default_preemption() {
     14Duration default_preemption() {
    1515        return PREEMPTION_RATE;
    1616}
  • src/tests/references.c

    r2efe4b8 r1cdfa82  
    4646
    4747int main() {
    48         int x = 123456, *p1 = &x, **p2 = &p1, ***p3 = &p2,
     48        int x = 123456, x2 = 789, *p1 = &x, **p2 = &p1, ***p3 = &p2,
    4949                &r1 = x,    &&r2 = r1,   &&&r3 = r2;
    5050        ***p3 = 3;                          // change x
     
    5252        *p3 = &p1;                          // change p2
    5353        int y = 0, z = 11, & ar[3] = { x, y, z };    // initialize array of references
     54        // &ar[1] = &z;                        // change reference array element
     55        // typeof( ar[1] ) p;                  // is int, i.e., the type of referenced object
     56        // typeof( &ar[1] ) q;                 // is int &, i.e., the type of reference
     57        // sizeof( ar[1] ) == sizeof( int );   // is true, i.e., the size of referenced object
     58        // sizeof( &ar[1] ) == sizeof( int *); // is true, i.e., the size of a reference
    5459
     60        ((int*&)&r3) = &x;                  // change r1, (&*)**r3
     61        x = 3;
    5562        // test that basic reference properties are true - r1 should be an alias for x
    5663        printf("%d %d %d\n", x, r1, &x == &r1);
     
    6875        printf("%d %d\n", r1, x);
    6976
     77        r3 = 6;                               // change x, ***r3
     78        printf("x = %d ; x2 = %d\n", x, x2);  // check that x was changed
     79        &r3 = &x2;                            // change r1 to refer to x2, (&*)**r3
     80        r3 = 999;                             // modify x2
     81        printf("x = %d ; x2 = %d\n", x, x2);  // check that x2 was changed
     82        ((int**&)&&r3) = p2;                  // change r2, (&(&*)*)*r3, ensure explicit cast to reference works
     83        r3 = 12345;                           // modify x
     84        printf("x = %d ; x2 = %d\n", x, x2);  // check that x was changed
     85        &&&r3 = p3;                           // change r3 to p3, (&(&(&*)*)*)r3
     86        ((int&)r3) = 22222;                   // modify x, ensure explicit cast to reference works
     87        printf("x = %d ; x2 = %d\n", x, x2);  // check that x was changed
     88
    7089        // test that reference members are not implicitly constructed/destructed/assigned
    7190        X x1, x2 = x1;
     
    7695        &z1.r = &z1r;
    7796        &z2.r = &z2r;
     97
    7898        z1 = z2;
     99
     100        // test rvalue-to-reference conversion
     101        {
     102                struct S { double x, y; };
     103                void f( int & i, int & j, S & s, int v[] ) {
     104                        printf("%d %d { %g, %g }, [%d, %d, %d]\n", i, j, s.[x, y], v[0], v[1], v[2]);
     105                }
     106                void g(int & i) { printf("%d\n", i); }
     107                void h(int &&& i) { printf("%d\n", i); }
     108
     109                int &&& r = 3;  // rvalue to reference
     110                int i = r;
     111                printf("%d %d\n", i, r);  // both 3
     112
     113                g( 3 );          // rvalue to reference
     114                h( (int &&&)3 ); // rvalue to reference
     115
     116                int a = 5, b = 4;
     117                f( 3, a + b, (S){ 1.0, 7.0 }, (int [3]){ 1, 2, 3 } ); // two rvalue to reference
     118        }
    79119}
    80120
  • tools/prettyprinter/Makefile.am

    r2efe4b8 r1cdfa82  
    1111## Created On       : Wed Jun 28 12:07:10 2017
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Wed Jun 28 23:11:56 2017
    14 ## Update Count     : 15
     13## Last Modified On : Mon Apr 16 09:43:23 2018
     14## Update Count     : 20
    1515###############################################################################
    1616
  • tools/prettyprinter/lex.ll

    r2efe4b8 r1cdfa82  
    1010 * Created On       : Sat Dec 15 11:45:59 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Tue Aug 29 17:33:36 2017
    13  * Update Count     : 268
     12 * Last Modified On : Sun Apr 15 21:28:33 2018
     13 * Update Count     : 271
    1414 */
    1515
     
    5050<INITIAL,C_CODE>"/*" {                                                                  // C style comments */
    5151#if defined(DEBUG_ALL) | defined(DEBUG_COMMENT)
    52     cerr << "\"/*\" : " << yytext << endl;
     52                cerr << "\"/*\" : " << yytext << endl;
    5353#endif
    54     if ( YYSTATE == C_CODE ) code_str += yytext;
    55     else comment_str += yytext;
    56     yy_push_state(C_COMMENT);
     54                if ( YYSTATE == C_CODE ) code_str += yytext;
     55                else comment_str += yytext;
     56                yy_push_state(C_COMMENT);
    5757}
    5858<C_COMMENT>(.|"\n")     {                                                                       // C style comments
    5959#if defined(DEBUG_ALL) | defined(DEBUG_COMMENT)
    60     cerr << "<C_COMMENT>(.|\\n) : " << yytext << endl;
     60                cerr << "<C_COMMENT>(.|\\n) : " << yytext << endl;
    6161#endif
    62     if ( yy_top_state() == C_CODE ) code_str += yytext;
    63     else comment_str += yytext;
     62                if ( yy_top_state() == C_CODE ) code_str += yytext;
     63                else comment_str += yytext;
    6464}
    6565<C_COMMENT>"*/" {                                                                               // C style comments
     
    123123<C_CODE>"%}"    { RETURN_TOKEN( RCURL ) }
    124124
    125 ^"%union"       { RETURN_TOKEN( UNION ) }
    126 ^"%start"       { RETURN_TOKEN( START ) }
    127 ^"%token"       { RETURN_TOKEN( TOKEN ) }
    128 ^"%type"            { RETURN_TOKEN( TYPE ) }
    129 ^"%left"            { RETURN_TOKEN( LEFT ) }
    130 ^"%right"           { RETURN_TOKEN( RIGHT ) }
    131 ^"%nonassoc"    { RETURN_TOKEN( NONASSOC ) }
    132 ^"%precedence"  { RETURN_TOKEN( PRECEDENCE ) }
     125^"%define"[^\n]*"\n" { RETURN_TOKEN( DEFINE ) }
     126^"%expect"              { RETURN_TOKEN( EXPECT ) }
     127^"%left"                { RETURN_TOKEN( LEFT ) }
     128^"%locations"   { RETURN_TOKEN( LOCATIONS ) }
     129^"%nonassoc"    { RETURN_TOKEN( NONASSOC ) }
     130^"%precedence"  { RETURN_TOKEN( PRECEDENCE ) }
    133131^"%pure_parser" { RETURN_TOKEN( PURE_PARSER ) }
     132^"%right"               { RETURN_TOKEN( RIGHT ) }
    134133^"%semantic_parser"     { RETURN_TOKEN( SEMANTIC_PARSER ) }
    135 ^"%expect"      { RETURN_TOKEN( EXPECT ) }
    136 ^"%thong"               { RETURN_TOKEN( THONG ) }
     134^"%start"               { RETURN_TOKEN( START ) }
     135^"%thong"               { RETURN_TOKEN( THONG ) }
     136^"%token"               { RETURN_TOKEN( TOKEN ) }
     137^"%type"                { RETURN_TOKEN( TYPE ) }
     138^"%union"               { RETURN_TOKEN( UNION ) }
    137139
    138 "%prec"                 { RETURN_TOKEN( PREC ) }
     140"%prec"                 { RETURN_TOKEN( PREC ) }
    139141
    140 {integer}           { RETURN_TOKEN( INTEGER ); }
    141 [']{c_char}[']  { RETURN_TOKEN( CHARACTER ); }
    142 {identifier}    { RETURN_TOKEN( IDENTIFIER ); }
     142{integer}               { RETURN_TOKEN( INTEGER ); }
     143[']{c_char}[']  { RETURN_TOKEN( CHARACTER ); }
     144{identifier}    { RETURN_TOKEN( IDENTIFIER ); }
    143145
    144146<C_CODE>["]{s_char}*["] {                                                               // hide braces "{}" in strings
     
    160162%%
    161163void lexC(void) {
    162     BEGIN(C_CODE);
     164        BEGIN(C_CODE);
    163165}
    164166
    165167string lexYacc(void) {
    166     BEGIN(INITIAL);
    167     //cerr << "CODE: " << endl << code_str << endl;
    168     string temp( code_str );
    169     code_str = "";
    170     return temp;
     168        BEGIN(INITIAL);
     169        //cerr << "CODE: " << endl << code_str << endl;
     170        string temp( code_str );
     171        code_str = "";
     172        return temp;
    171173}
    172174
  • tools/prettyprinter/parser.yy

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat Dec 15 13:44:21 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 29 16:34:10 2017
    13 // Update Count     : 1047
     12// Last Modified On : Sun Apr 15 21:40:30 2018
     13// Update Count     : 1052
    1414//
    1515
     
    6161%token<tokenp>  CODE                                                                    // C code
    6262
    63 %token<tokenp>  START                                                                   // %start
    64 %token<tokenp>  UNION                                                                   // %union
    65 %token<tokenp>  TOKEN                                                                   // %token
     63%token<tokenp>  DEFINE                                                                  // %define
     64%token<tokenp>  EXPECT                                                                  // %expect
    6665%token<tokenp>  LEFT                                                                    // %left
    67 %token<tokenp>  RIGHT                                                                   // %right
     66%token<tokenp>  LOCATIONS                                                               // %locations
    6867%token<tokenp>  NONASSOC                                                                // %nonassoc
    6968%token<tokenp>  PRECEDENCE                                                              // %precedence
     69%token<tokenp>  PURE_PARSER                                                             // %pure_parser
     70%token<tokenp>  RIGHT                                                                   // %right
     71%token<tokenp>  SEMANTIC_PARSER                                                 // %semantic_parser
     72%token<tokenp>  START                                                                   // %start
     73%token<tokenp>  THONG                                                                   // %thong
     74%token<tokenp>  TOKEN                                                                   // %token
    7075%token<tokenp>  TYPE                                                                    // %type
    71 %token<tokenp>  PURE_PARSER                                                             // %pure_parser
    72 %token<tokenp>  SEMANTIC_PARSER                                                 // %semantic_parser
    73 %token<tokenp>  EXPECT                                                                  // %expect
    74 %token<tokenp>  THONG                                                                   // %thong
     76%token<tokenp>  UNION                                                                   // %union
    7577
    7678%token<tokenp>  PREC                                                                    // %prec
    7779
    78 %token          END_TERMINALS                                                           // ALL TERMINAL TOKEN NAMES MUST APPEAR BEFORE THIS
     80%token                  END_TERMINALS                                                   // ALL TERMINAL TOKEN NAMES MUST APPEAR BEFORE THIS
    7981
    8082%type<tokenp>   sections
    81 %token          _SECTIONS
     83%token                  _SECTIONS
    8284%type<tokenp>   mark
    8385%type<tokenp>   defsection_opt
    84 %token          _DEFSECTION_OPT
     86%token                  _DEFSECTION_OPT
    8587%type<tokenp>   declarations
    8688%type<tokenp>   literalblock
    87 %token          _LITERALBLOCK
     89%token                  _LITERALBLOCK
    8890%type<tokenp>   declaration
    89 %token          _DECLARATION
     91%token                  _DECLARATION
    9092%type<tokenp>   union
    9193%type<tokenp>   rword
    9294%type<tokenp>   tag_opt
    93 %token          _TAG_OPT
     95%token                  _TAG_OPT
    9496%type<tokenp>   namenolist
    95 %token          _NAMENOLIST
     97%token                  _NAMENOLIST
    9698%type<tokenp>   nameno
    97 %token          _NAMENO
     99%token                  _NAMENO
    98100%type<tokenp>   namelist
    99 %token          _NAMELIST
     101%token                  _NAMELIST
    100102%type<tokenp>   name
    101103%type<tokenp>   rulesection
    102 %token          _RULESECTION
     104%token                  _RULESECTION
    103105%type<tokenp>   rules
    104 %token          _RULE
     106%token                  _RULE
    105107%type<tokenp>   lhs
    106 %token          _LHS
     108%token                  _LHS
    107109%type<tokenp>   rhs
    108 %token          _RHS
     110%token                  _RHS
    109111%type<tokenp>   prod
    110112%type<tokenp>   prec
    111 %token          _PREC
     113%token                  _PREC
    112114%type<tokenp>   action
    113 %token          _ACTION
     115%token                  _ACTION
    114116%type<tokenp>   usersection_opt
    115 %token          _USERSECTION_OPT
     117%token                  _USERSECTION_OPT
    116118%type<tokenp>   ccode_opt
    117119%type<tokenp>   blocks
     
    234236                    $$ = $1;
    235237                }
     238        | DEFINE                                                                                        // bison
     239        | LOCATIONS
    236240        | THONG                                                                                         // bison
    237241        ;
  • tools/prettyprinter/test.y

    r2efe4b8 r1cdfa82  
    66
    77/* adsad2 */
    8 
     8%locations
     9%define parse.error verbose
    910%%
    1011
Note: See TracChangeset for help on using the changeset viewer.