Changes in / [fae2cf8:65aca88]


Ignore:
Files:
11 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • Jenkins/FullBuild

    rfae2cf8 r65aca88  
    161161"""
    162162
    163         def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com, ajbeach@edu.uwaterloo.ca"
     163        def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com"
    164164
    165165        //send email notification
  • Jenkinsfile

    rfae2cf8 r65aca88  
    153153        do_sendemail    = ! (pSilent == 'true')
    154154
    155         echo """Compiler              : ${compiler.cc_name} (${compiler.cpp_cc}/${compiler.cfa_cc})
    156 Architecture            : ${arch_name}
    157 Arc Flags               : ${architecture}
    158 Run All Tests           : ${ pRunAllTests.toString() }
    159 Run Benchmark           : ${ pRunBenchmark.toString() }
    160 Build Documentation     : ${ pBuildDocumentation.toString() }
    161 Publish                 : ${ pPublish.toString() }
    162 Silent                  : ${ pSilent.toString() }
     155        echo """Compiler                : ${compiler.cc_name} (${compiler.cpp_cc}/${compiler.cfa_cc})
     156Architecture            : ${arch_name}
     157Arc Flags               : ${architecture}
     158Run All Tests           : ${ pRunAllTests.toString() }
     159Run Benchmark           : ${ pRunBenchmark.toString() }
     160Build Documentation     : ${ pBuildDocumentation.toString() }
     161Publish         : ${ pPublish.toString() }
     162Silent                  : ${ pSilent.toString() }
    163163"""
    164164
  • doc/LaTeXmacros/common.tex

    rfae2cf8 r65aca88  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Sun May 14 18:17:09 2017
    14 %% Update Count     : 295
     13%% Last Modified On : Tue Apr 18 17:16:13 2017
     14%% Update Count     : 270
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    3636% Names used in the document.
    3737
    38 \newcommand{\CFA}{C\raisebox{\depth}{\rotatebox{180}{\textscale{1.05}{\textsf{A}}}}\xspace} % Cforall symbolic name
     38\newcommand{\CFA}{C$\mathbf\forall$\xspace} % Cforall symbolic name
    3939\newcommand{\CFL}{Cforall\xspace} % Cforall symbolic name
    40 \newcommand{\Celeven}{C11\xspace} % C11 symbolic name
    4140\newcommand{\CC}{\rm C\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name
    4241\newcommand{\CCeleven}{\rm C\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name
     
    4443\newcommand{\CCseventeen}{\rm C\kern-.1em\hbox{+\kern-.25em+}17\xspace} % C++17 symbolic name
    4544\newcommand{\CCtwenty}{\rm C\kern-.1em\hbox{+\kern-.25em+}20\xspace} % C++20 symbolic name
     45\newcommand{\Celeven}{C11\xspace} % C11 symbolic name
    4646\newcommand{\Csharp}{C\raisebox{-0.7ex}{\Large$^\sharp$}\xspace} % C# symbolic name
    4747
     
    6767\usepackage{pslatex}                                    % reduce size of san serif font
    6868\usepackage{relsize}                                    % must be after change to small or selects old size
    69 \usepackage{rotating}
    7069
    7170% reduce size of chapter/section titles
     
    9897\newcommand{\italic}[1]{\emph{\hyperpage{#1}}}
    9998\newcommand{\definition}[1]{\textbf{\hyperpage{#1}}}
    100 \newcommand{\see}[1]{\emph{see}~#1}
     99\newcommand{\see}[1]{\emph{see} #1}
    101100
    102101% Define some commands that produce formatted index entries suitable for cross-references.
     
    222221}%
    223222
    224 \usepackage{lstlang}
     223% Go programming language: https://github.com/julienc91/listings-golang/blob/master/listings-golang.sty
     224\lstdefinelanguage{Golang}{
     225        morekeywords=[1]{package,import,func,type,struct,return,defer,panic,recover,select,var,const,iota,},%
     226        morekeywords=[2]{string,uint,uint8,uint16,uint32,uint64,int,int8,int16,int32,int64,
     227                bool,float32,float64,complex64,complex128,byte,rune,uintptr, error,interface},%
     228        morekeywords=[3]{map,slice,make,new,nil,len,cap,copy,close,true,false,delete,append,real,imag,complex,chan,},%
     229        morekeywords=[4]{for,break,continue,range,goto,switch,case,fallthrough,if,else,default,},%
     230        morekeywords=[5]{Println,Printf,Error,},%
     231        sensitive=true,%
     232        morecomment=[l]{//},%
     233        morecomment=[s]{/*}{*/},%
     234        morestring=[b]',%
     235        morestring=[b]",%
     236        morestring=[s]{`}{`},%
     237}
     238
     239% CFA programming language, based on ANSI C (with some gcc additions)
     240\lstdefinelanguage{Pseudo}{
     241        morekeywords={string,uint,int,bool,float},%
     242        sensitive=true,%
     243        morecomment=[l]{//},%
     244        morecomment=[s]{/*}{*/},%
     245        morestring=[b]',%
     246        morestring=[b]",%
     247        morestring=[s]{`}{`},%
     248}%
     249
     250% CFA programming language, based on ANSI C (with some gcc additions)
     251\lstdefinelanguage{CFA}[ANSI]{C}{
     252        morekeywords={_Alignas,_Alignof,__alignof,__alignof__,asm,__asm,__asm__,_At,_Atomic,__attribute,__attribute__,auto,
     253                _Bool,catch,catchResume,choose,_Complex,__complex,__complex__,__const,__const__,coroutine,disable,dtype,enable,__extension__,
     254                fallthrough,fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,__label__,lvalue,monitor,mutex,_Noreturn,one_t,otype,restrict,_Static_assert,
     255                thread,_Thread_local,throw,throwResume,trait,try,ttype,typeof,__typeof,__typeof__,zero_t},
     256}%
    225257
    226258\newcommand{\CFADefaults}{%
     
    260292{}
    261293
     294
    262295% Local Variables: %
    263296% tab-width: 4 %
  • doc/generic_types/generic_types.tex

    rfae2cf8 r65aca88  
    66\usepackage{upquote}                                                                    % switch curled `'" to straight
    77\usepackage{listings}                                                                   % format program code
    8 \usepackage{rotating}
    98\usepackage[usenames]{color}
    109
     
    4948
    5049% Useful macros
    51 \newcommand{\CFA}{C\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\hspace{-1pt}\xspace} % Cforall symbolic name
    52 %\newcommand{\CFA}{C$\mathbf\forall$\xspace} % Cforall symbolic name
     50\newcommand{\CFA}{C$\mathbf\forall$\xspace} % Cforall symbolic name
    5351\newcommand{\CC}{\rm C\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name
    5452\newcommand{\CCeleven}{\rm C\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name
     
    9997\acmJournal{PACMPL}
    10098
    101 \title{Generic and Tuple Types with Efficient Dynamic Layout in \protect\CFA}
     99\title{Generic and Tuple Types with Efficient Dynamic Layout in \CFA}
    102100
    103101\author{Aaron Moss}
     
    199197\label{sec:poly-fns}
    200198
    201 \CFA{}\hspace{1pt}'s polymorphism was originally formalized by \citet{Ditchfield92}, and first implemented by \citet{Bilson03}.
     199\CFA's polymorphism was originally formalized by \citet{Ditchfield92}, and first implemented by \citet{Bilson03}.
    202200The signature feature of \CFA is parametric-polymorphic functions~\citep{forceone:impl,Cormack90,Duggan96} with functions generalized using a @forall@ clause (giving the language its name):
    203201\begin{lstlisting}
     
    952950}
    953951\end{lstlisting}
    954 \caption{\protect\CFA Benchmark Test}
     952\caption{\CFA Benchmark Test}
    955953\label{fig:BenchmarkTest}
    956954\end{figure}
     
    10221020While \CC provides good backwards compatibility with C, it has a steep learning curve for many of its extensions.
    10231021For example, polymorphism is provided via three disjoint mechanisms: overloading, inheritance, and templates.
    1024 The overloading is restricted because resolution does not use the return type, inheritance requires learning object-oriented programming and coping with a restricted nominal-inheritance hierarchy, templates cannot be separately compiled resulting in compilation/code bloat and poor error messages, and determining how these mechanisms interact and which to use is confusing.
     1022The overloading is restricted because resolution does not using the return type, inheritance requires learning object-oriented programming and coping with a restricted nominal-inheritance hierarchy, templates cannot be separately compiled resulting in compilation/code bloat and poor error messages, and determining how these mechanisms interact and which to use is confusing.
    10251023In contrast, \CFA has a single facility for polymorphic code supporting type-safe separate-compilation of polymorphic functions and generic (opaque) types, which uniformly leverage the C procedural paradigm.
    10261024The key mechanism to support separate compilation is \CFA's \emph{explicit} use of assumed properties for a type.
  • doc/rob_thesis/thesis.bib

    • Property mode changed from 100644 to 100755
  • doc/user/Makefile

    rfae2cf8 r65aca88  
    4747
    4848${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \
    49                 ../LaTeXmacros/common.tex ../LaTeXmacros/lstlang.sty ../LaTeXmacros/indexstyle ../bibliography/cfa.bib
     49                ../LaTeXmacros/common.tex ../LaTeXmacros/indexstyle ../bibliography/cfa.bib
    5050        # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run.
    5151        if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi
  • src/GenPoly/Box.cc

    rfae2cf8 r65aca88  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May 13 09:26:38 2017
    13 // Update Count     : 341
     12// Last Modified On : Fri Mar 17 09:06:37 2017
     13// Update Count     : 339
    1414//
    1515
     
    706706                                Type *concrete = env->lookup( typeInst->get_name() );
    707707                                if ( concrete == 0 ) {
    708                                         return typeInst;
    709708                                        // xxx - should this be an assertion?
    710 //                                      std::string x = env ? toString( *env ) : "missing env";
    711 //                                      throw SemanticError( x + "\n" + "Unbound type variable " + typeInst->get_name() + " in ", appExpr );
     709                                        std::string x = env ? toString( *env ) : "missing env";
     710                                        throw SemanticError( x + "\n" + "Unbound type variable " + typeInst->get_name() + " in ", appExpr );
    712711                                } // if
    713712                                return concrete;
  • src/libcfa/Makefile.am

    rfae2cf8 r65aca88  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sun May 14 21:04:21 2017
    14 ## Update Count     : 214
     13## Last Modified On : Sat Mar 25 18:00:10 2017
     14## Update Count     : 212
    1515###############################################################################
    1616
     
    7676
    7777cfa_includedir = $(CFA_INCDIR)
    78 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} gmp concurrency/invoke.h
     78nobase_cfa_include_HEADERS = ${headers} ${stdhdr} concurrency/invoke.h
    7979
    8080CLEANFILES = libcfa-prelude.c
  • src/libcfa/Makefile.in

    rfae2cf8 r65aca88  
    183183        containers/vector concurrency/coroutine concurrency/thread \
    184184        concurrency/kernel concurrency/monitor ${shell echo stdhdr/*} \
    185         gmp concurrency/invoke.h
     185        concurrency/invoke.h
    186186HEADERS = $(nobase_cfa_include_HEADERS)
    187187ETAGS = etags
     
    324324stdhdr = ${shell echo stdhdr/*}
    325325cfa_includedir = $(CFA_INCDIR)
    326 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} gmp concurrency/invoke.h
     326nobase_cfa_include_HEADERS = ${headers} ${stdhdr} concurrency/invoke.h
    327327CLEANFILES = libcfa-prelude.c
    328328all: all-am
  • src/libcfa/iostream.c

    rfae2cf8 r65aca88  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May  8 18:24:23 2017
    13 // Update Count     : 369
     12// Last Modified On : Thu Mar 23 08:20:40 2017
     13// Update Count     : 367
    1414//
    1515
     
    160160                [(unsigned char)'¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open,
    161161                // closing delimiters, no space before
    162                 [','] : Close, ['.'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close,
     162                [','] : Close, ['.'] : Close, [':'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close,
    163163                ['%'] : Close, [(unsigned char)'¢'] : Close, [(unsigned char)'»'] : Close,
    164164                [')'] : Close, [']'] : Close, ['}'] : Close,
    165165                // opening-closing delimiters, no space before or after
    166                 ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose, [':'] : OpenClose,
     166                ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose,
    167167                [' '] : OpenClose, ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace
    168168        }; // mask
  • src/libcfa/rational

    rfae2cf8 r65aca88  
    1212// Created On       : Wed Apr  6 17:56:25 2016
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Sun May 14 16:49:13 2017
    15 // Update Count     : 78
     14// Last Modified On : Mon May  1 08:25:06 2017
     15// Update Count     : 33
    1616//
    1717
     
    2121#include "iostream"
    2222
    23 trait scalar( otype T ) {
    24 };
    25 
    26 trait arithmetic( otype T | scalar( T ) ) {
    27         int !?( T );
    28         int ?==?( T, T );
    29         int ?!=?( T, T );
    30         int ?<?( T, T );
    31         int ?<=?( T, T );
    32         int ?>?( T, T );
    33         int ?>=?( T, T );
    34         void ?{}( T *, zero_t );
    35         void ?{}( T *, one_t );
    36         T +?( T );
    37         T -?( T );
    38         T ?+?( T, T );
    39         T ?-?( T, T );
    40         T ?*?( T, T );
    41         T ?/?( T, T );
    42         T ?%?( T, T );
    43         T ?/=?( T *, T );
    44         T abs( T );
    45 };
    46 
    4723// implementation
    48 
    49 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     24typedef long int RationalImpl;
    5025struct Rational {
    51         RationalImpl numerator, denominator;                            // invariant: denominator > 0
     26        RationalImpl numerator, denominator;                                    // invariant: denominator > 0
    5227}; // Rational
    5328
     29// constants
     30extern struct Rational 0;
     31extern struct Rational 1;
     32
    5433// constructors
    55 
    56 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    57 void ?{}( Rational(RationalImpl) * r );
    58 
    59 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    60 void ?{}( Rational(RationalImpl) * r, RationalImpl n );
    61 
    62 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    63 void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d );
    64 
    65 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    66 void ?{}( Rational(RationalImpl) * r, zero_t );
    67 
    68 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    69 void ?{}( Rational(RationalImpl) * r, one_t );
     34void ?{}( Rational * r );
     35void ?{}( Rational * r, RationalImpl n );
     36void ?{}( Rational * r, RationalImpl n, RationalImpl d );
    7037
    7138// getter for numerator/denominator
    72 
    73 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    74 RationalImpl numerator( Rational(RationalImpl) r );
    75 
    76 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    77 RationalImpl denominator( Rational(RationalImpl) r );
    78 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    79 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );
    80 
     39RationalImpl numerator( Rational r );
     40RationalImpl denominator( Rational r );
     41[ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational src );
    8142// setter for numerator/denominator
    82 
    83 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    84 RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n );
    85 
    86 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    87 RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d );
     43RationalImpl numerator( Rational r, RationalImpl n );
     44RationalImpl denominator( Rational r, RationalImpl d );
    8845
    8946// comparison
    90 
    91 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    92 int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    93 
    94 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    95 int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    96 
    97 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    98 int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    99 
    100 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    101 int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    102 
    103 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    104 int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    105 
    106 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    107 int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     47int ?==?( Rational l, Rational r );
     48int ?!=?( Rational l, Rational r );
     49int ?<?( Rational l, Rational r );
     50int ?<=?( Rational l, Rational r );
     51int ?>?( Rational l, Rational r );
     52int ?>=?( Rational l, Rational r );
    10853
    10954// arithmetic
    110 
    111 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    112 Rational(RationalImpl) +?( Rational(RationalImpl) r );
    113 
    114 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    115 Rational(RationalImpl) -?( Rational(RationalImpl) r );
    116 
    117 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    118 Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    119 
    120 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    121 Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    122 
    123 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    124 Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    125 
    126 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    127 Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     55Rational -?( Rational r );
     56Rational ?+?( Rational l, Rational r );
     57Rational ?-?( Rational l, Rational r );
     58Rational ?*?( Rational l, Rational r );
     59Rational ?/?( Rational l, Rational r );
    12860
    12961// conversion
    130 // forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    131 // double widen( Rational(RationalImpl) r );
    132 // forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    133 // Rational(RationalImpl) narrow( double f, RationalImpl md );
     62double widen( Rational r );
     63Rational narrow( double f, RationalImpl md );
    13464
    13565// I/O
    136 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    137 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
    138 istype * ?|?( istype *, Rational(RationalImpl) * );
    139 
    140 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    141 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
    142 ostype * ?|?( ostype *, Rational(RationalImpl ) );
     66forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, Rational * );
     67forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, Rational );
    14368
    14469#endif // RATIONAL_H
  • src/libcfa/rational.c

    rfae2cf8 r65aca88  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 14 17:25:19 2017
    13 // Update Count     : 131
     12// Last Modified On : Thu Apr 27 17:05:06 2017
     13// Update Count     : 51
    1414//
    1515
     
    1717#include "fstream"
    1818#include "stdlib"
     19#include "math"                                                                                 // floor
     20
     21
     22// constants
     23
     24struct Rational 0 = {0, 1};
     25struct Rational 1 = {1, 1};
     26
    1927
    2028// helper routines
     
    2230// Calculate greatest common denominator of two numbers, the first of which may be negative. Used to reduce rationals.
    2331// alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm
    24 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    2532static RationalImpl gcd( RationalImpl a, RationalImpl b ) {
    2633        for ( ;; ) {                                                                            // Euclid's algorithm
    2734                RationalImpl r = a % b;
    28           if ( r == (RationalImpl){0} ) break;
     35          if ( r == 0 ) break;
    2936                a = b;
    3037                b = r;
     
    3340} // gcd
    3441
    35 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    36 static RationalImpl simplify( RationalImpl * n, RationalImpl * d ) {
    37         if ( *d == (RationalImpl){0} ) {
     42static RationalImpl simplify( RationalImpl *n, RationalImpl *d ) {
     43        if ( *d == 0 ) {
    3844                serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl;
    3945                exit( EXIT_FAILURE );
    4046        } // exit
    41         if ( *d < (RationalImpl){0} ) { *d = -*d; *n = -*n; } // move sign to numerator
     47        if ( *d < 0 ) { *d = -*d; *n = -*n; }                           // move sign to numerator
    4248        return gcd( abs( *n ), *d );                                            // simplify
    4349} // Rationalnumber::simplify
     
    4652// constructors
    4753
    48 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    49 void ?{}( Rational(RationalImpl) * r ) {
    50         r{ (RationalImpl){0}, (RationalImpl){1} };
     54void ?{}( Rational * r ) {
     55        r{ 0, 1 };
    5156} // rational
    5257
    53 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    54 void ?{}( Rational(RationalImpl) * r, RationalImpl n ) {
    55         r{ n, (RationalImpl){1} };
     58void ?{}( Rational * r, RationalImpl n ) {
     59        r{ n, 1 };
    5660} // rational
    5761
    58 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    59 void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d ) {
     62void ?{}( Rational * r, RationalImpl n, RationalImpl d ) {
    6063        RationalImpl t = simplify( &n, &d );                            // simplify
    6164        r->numerator = n / t;
     
    6669// getter for numerator/denominator
    6770
    68 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    69 RationalImpl numerator( Rational(RationalImpl) r ) {
     71RationalImpl numerator( Rational r ) {
    7072        return r.numerator;
    7173} // numerator
    7274
    73 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    74 RationalImpl denominator( Rational(RationalImpl) r ) {
     75RationalImpl denominator( Rational r ) {
    7576        return r.denominator;
    7677} // denominator
    7778
    78 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    79 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) {
     79[ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational src ) {
    8080        return *dest = src.[ numerator, denominator ];
    8181}
     
    8383// setter for numerator/denominator
    8484
    85 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    86 RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n ) {
     85RationalImpl numerator( Rational r, RationalImpl n ) {
    8786        RationalImpl prev = r.numerator;
    8887        RationalImpl t = gcd( abs( n ), r.denominator );                // simplify
     
    9291} // numerator
    9392
    94 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    95 RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ) {
     93RationalImpl denominator( Rational r, RationalImpl d ) {
    9694        RationalImpl prev = r.denominator;
    9795        RationalImpl t = simplify( &r.numerator, &d );                  // simplify
     
    104102// comparison
    105103
    106 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    107 int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
     104int ?==?( Rational l, Rational r ) {
    108105        return l.numerator * r.denominator == l.denominator * r.numerator;
    109106} // ?==?
    110107
    111 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    112 int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
     108int ?!=?( Rational l, Rational r ) {
    113109        return ! ( l == r );
    114110} // ?!=?
    115111
    116 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    117 int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
     112int ?<?( Rational l, Rational r ) {
    118113        return l.numerator * r.denominator < l.denominator * r.numerator;
    119114} // ?<?
    120115
    121 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    122 int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    123         return l.numerator * r.denominator <= l.denominator * r.numerator;
     116int ?<=?( Rational l, Rational r ) {
     117        return l < r || l == r;
    124118} // ?<=?
    125119
    126 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    127 int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
     120int ?>?( Rational l, Rational r ) {
    128121        return ! ( l <= r );
    129122} // ?>?
    130123
    131 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    132 int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
     124int ?>=?( Rational l, Rational r ) {
    133125        return ! ( l < r );
    134126} // ?>=?
     
    137129// arithmetic
    138130
    139 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    140 Rational(RationalImpl) +?( Rational(RationalImpl) r ) {
    141         Rational(RationalImpl) t = { r.numerator, r.denominator };
    142         return t;
    143 } // +?
    144 
    145 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    146 Rational(RationalImpl) -?( Rational(RationalImpl) r ) {
    147         Rational(RationalImpl) t = { -r.numerator, r.denominator };
     131Rational -?( Rational r ) {
     132        Rational t = { -r.numerator, r.denominator };
    148133        return t;
    149134} // -?
    150135
    151 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    152 Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
     136Rational ?+?( Rational l, Rational r ) {
    153137        if ( l.denominator == r.denominator ) {                         // special case
    154                 Rational(RationalImpl) t = { l.numerator + r.numerator, l.denominator };
     138                Rational t = { l.numerator + r.numerator, l.denominator };
    155139                return t;
    156140        } else {
    157                 Rational(RationalImpl) t = { l.numerator * r.denominator + l.denominator * r.numerator, l.denominator * r.denominator };
     141                Rational t = { l.numerator * r.denominator + l.denominator * r.numerator, l.denominator * r.denominator };
    158142                return t;
    159143        } // if
    160144} // ?+?
    161145
    162 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    163 Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
     146Rational ?-?( Rational l, Rational r ) {
    164147        if ( l.denominator == r.denominator ) {                         // special case
    165                 Rational(RationalImpl) t = { l.numerator - r.numerator, l.denominator };
     148                Rational t = { l.numerator - r.numerator, l.denominator };
    166149                return t;
    167150        } else {
    168                 Rational(RationalImpl) t = { l.numerator * r.denominator - l.denominator * r.numerator, l.denominator * r.denominator };
     151                Rational t = { l.numerator * r.denominator - l.denominator * r.numerator, l.denominator * r.denominator };
    169152                return t;
    170153        } // if
    171154} // ?-?
    172155
    173 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    174 Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    175         Rational(RationalImpl) t = { l.numerator * r.numerator, l.denominator * r.denominator };
     156Rational ?*?( Rational l, Rational r ) {
     157        Rational t = { l.numerator * r.numerator, l.denominator * r.denominator };
    176158        return t;
    177159} // ?*?
    178160
    179 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    180 Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    181         if ( r.numerator < (RationalImpl){0} ) {
     161Rational ?/?( Rational l, Rational r ) {
     162        if ( r.numerator < 0 ) {
    182163                r.numerator = -r.numerator;
    183164                r.denominator = -r.denominator;
    184165        } // if
    185         Rational(RationalImpl) t = { l.numerator * r.denominator, l.denominator * r.numerator };
     166        Rational t = { l.numerator * r.denominator, l.denominator * r.numerator };
    186167        return t;
    187168} // ?/?
     
    190171// conversion
    191172
    192 // forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    193 // double widen( Rational(RationalImpl) r ) {
    194 //      return (double)r.numerator / (double)r.denominator;
    195 // } // widen
    196 
    197 // // http://www.ics.uci.edu/~eppstein/numth/frap.c
    198 // forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    199 // Rational(RationalImpl) narrow( double f, RationalImpl md ) {
    200 //      if ( md <= 1 ) {                                                                        // maximum fractional digits too small?
    201 //              return (Rational(RationalImpl)){ f, 1};                 // truncate fraction
    202 //      } // if
    203 
    204 //      // continued fraction coefficients
    205 //      RationalImpl m00 = 1, m11 = 1, m01 = 0, m10 = 0;
    206 //      RationalImpl ai, t;
    207 
    208 //      // find terms until denom gets too big
    209 //      for ( ;; ) {
    210 //              ai = (RationalImpl)f;
    211 //        if ( ! (m10 * ai + m11 <= md) ) break;
    212 //              t = m00 * ai + m01;
    213 //              m01 = m00;
    214 //              m00 = t;
    215 //              t = m10 * ai + m11;
    216 //              m11 = m10;
    217 //              m10 = t;
    218 //              t = (double)ai;
    219 //        if ( f == t ) break;                                                          // prevent division by zero
    220 //        f = 1 / (f - (double)t);
    221 //        if ( f > (double)0x7FFFFFFF ) break;                          // representation failure
    222 //      }
    223 //      return (Rational(RationalImpl)){ m00, m10 };
    224 // } // narrow
     173double widen( Rational r ) {
     174        return (double)r.numerator / (double)r.denominator;
     175} // widen
     176
     177// http://www.ics.uci.edu/~eppstein/numth/frap.c
     178Rational narrow( double f, RationalImpl md ) {
     179        if ( md <= 1 ) {                                                                        // maximum fractional digits too small?
     180                return (Rational){ f, 1};                                               // truncate fraction
     181        } // if
     182
     183        // continued fraction coefficients
     184        RationalImpl m00 = 1, m11 = 1, m01 = 0, m10 = 0;
     185        RationalImpl ai, t;
     186
     187        // find terms until denom gets too big
     188        for ( ;; ) {
     189                ai = (RationalImpl)f;
     190          if ( ! (m10 * ai + m11 <= md) ) break;
     191                t = m00 * ai + m01;
     192                m01 = m00;
     193                m00 = t;
     194                t = m10 * ai + m11;
     195                m11 = m10;
     196                m10 = t;
     197                t = (double)ai;
     198          if ( f == t ) break;                                                          // prevent division by zero
     199                f = 1 / (f - t);
     200          if ( f > (double)0x7FFFFFFF ) break;                          // representation failure
     201        }
     202        return (Rational){ m00, m10 };
     203} // narrow
    225204
    226205
    227206// I/O
    228207
    229 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    230 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
    231 istype * ?|?( istype * is, Rational(RationalImpl) * r ) {
     208forall( dtype istype | istream( istype ) )
     209istype * ?|?( istype *is, Rational *r ) {
    232210        RationalImpl t;
    233211        is | &(r->numerator) | &(r->denominator);
     
    238216} // ?|?
    239217
    240 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    241 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
    242 ostype * ?|?( ostype * os, Rational(RationalImpl ) r ) {
     218forall( dtype ostype | ostream( ostype ) )
     219ostype * ?|?( ostype *os, Rational r ) {
    243220        return os | r.numerator | '/' | r.denominator;
    244221} // ?|?
  • src/libcfa/stdlib

    rfae2cf8 r65aca88  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May  9 08:42:44 2017
    13 // Update Count     : 107
     12// Last Modified On : Sat Apr  1 17:35:24 2017
     13// Update Count     : 104
    1414//
    1515
     
    8484forall( otype T | { int ?<?( T, T ); } )
    8585T * bsearch( T key, const T * arr, size_t dimension );
    86 
    8786forall( otype T | { int ?<?( T, T ); } )
    8887unsigned int bsearch( T key, const T * arr, size_t dimension );
    89 
    9088
    9189forall( otype T | { int ?<?( T, T ); } )
     
    109107double abs( double _Complex );
    110108long double abs( long double _Complex );
    111 forall ( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } )
    112 T abs( T );
    113109
    114110//---------------------------------------
  • src/libcfa/stdlib.c

    rfae2cf8 r65aca88  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May  9 08:43:00 2017
    13 // Update Count     : 191
     12// Last Modified On : Sun Apr 16 10:41:05 2017
     13// Update Count     : 189
    1414//
    1515
     
    2727} // extern "C"
    2828
    29 forall( dtype T | sized(T) ) T * malloc( void ) {               // type-safe
    30     return (T *)(void *)malloc( (size_t)sizeof(T) );
    31 } // malloc
    32 
    33 forall( dtype T | sized(T) ) T * malloc( char fill ) {  // initial with fill value (like calloc)
    34         T * ptr = (T *)(void *)malloc( (size_t)sizeof(T) );
     29forall( dtype T | sized(T) ) T * malloc( void ) {
     30        //printf( "malloc1\n" );
     31    return (T *)(void*)malloc( (size_t)sizeof(T) );
     32} // malloc
     33forall( dtype T | sized(T) ) T * malloc( char fill ) {
     34        //printf( "malloc3\n" );
     35        T * ptr = (T *)(void*)malloc( (size_t)sizeof(T) );
    3536    return memset( ptr, (int)fill, sizeof(T) );
    3637} // malloc
    3738
    38 forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size ) { // alternative realloc
    39     return (T *)realloc( ptr, size );
    40 } // malloc
    41 
    42 forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size, unsigned char fill ) { // alternative realloc with fill value
    43     return (T *)realloc( ptr, size, fill );
    44 } // malloc
    45 
    46 
    47 forall( dtype T | sized(T) ) T * calloc( size_t nmemb ) { // type-safe array initialization with fill 0
     39forall( dtype T | sized(T) ) T * calloc( size_t nmemb ) {
     40        //printf( "calloc\n" );
    4841    return (T *)calloc( nmemb, sizeof(T) );
    4942} // calloc
    5043
    51 
    52 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) { // type-safe
     44forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) {
     45        //printf( "realloc1\n" );
    5346    return (T *)(void *)realloc( (void *)ptr, size );
    5447} // realloc
    55 
    56 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) { // alternative realloc with fill value
     48forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) {
     49        //printf( "realloc2\n" );
    5750    char * nptr = (T *)(void *)realloc( (void *)ptr, size );
    5851    size_t unused = malloc_usable_size( nptr );
     
    6154} // realloc
    6255
    63 
    64 forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ) { // aligned allocation
     56forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size ) {
     57        //printf( "malloc4\n" );
     58    return (T *)realloc( ptr, size );
     59} // malloc
     60forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size, unsigned char fill ) {
     61        //printf( "malloc5\n" );
     62    return (T *)realloc( ptr, size, fill );
     63} // malloc
     64
     65forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ) {
     66        //printf( "aligned_alloc\n" );
    6567    return (T *)memalign( alignment, sizeof(T) );
    6668} // aligned_alloc
    6769
    6870forall( dtype T | sized(T) ) T * memalign( size_t alignment ) {
     71        //printf( "memalign\n" );
    6972    return (T *)memalign( alignment, sizeof(T) );
    7073} // memalign
    7174
    7275forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment ) {
     76        //printf( "posix_memalign\n" );
    7377    return posix_memalign( (void **)ptr, alignment, sizeof(T) );
    7478} // posix_memalign
    7579
    76 
    77 forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } ) //  new
     80forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } )
    7881T * new( Params p ) {
    7982        return ((T *)malloc()){ p };
    80 } // new
    81 
    82 forall( dtype T | { void ^?{}(T *); } )                                 // delete
     83}
     84
     85forall( dtype T | { void ^?{}(T *); } )
    8386void delete( T * ptr ) {
    84         if ( ptr ) {
    85                 ^ptr{};
    86                 free( ptr );
    87         }
    88 } // delete
     87  if ( ptr ) {
     88    ^ptr{};
     89    free( ptr );
     90  }
     91}
    8992
    9093forall( dtype T, ttype Params | { void ^?{}(T *); void delete(Params); } )
     
    9598        }
    9699        delete( rest );
    97 } // delete
     100}
    98101
    99102//---------------------------------------
     
    103106        if ( sscanf( ptr, "%d", &i ) == EOF ) {}
    104107        return i;
    105 } // ato
    106 
     108}
    107109unsigned int ato( const char * ptr ) {
    108110        unsigned int ui;
    109111        if ( sscanf( ptr, "%u", &ui ) == EOF ) {}
    110112        return ui;
    111 } // ato
    112 
     113}
    113114long int ato( const char * ptr ) {
    114115        long int li;
    115116        if ( sscanf( ptr, "%ld", &li ) == EOF ) {}
    116117        return li;
    117 } // ato
    118 
     118}
    119119unsigned long int ato( const char * ptr ) {
    120120        unsigned long int uli;
    121121        if ( sscanf( ptr, "%lu", &uli ) == EOF ) {}
    122122        return uli;
    123 } // ato
    124 
     123}
    125124long long int ato( const char * ptr ) {
    126125        long long int lli;
    127126        if ( sscanf( ptr, "%lld", &lli ) == EOF ) {}
    128127        return lli;
    129 } // ato
    130 
     128}
    131129unsigned long long int ato( const char * ptr ) {
    132130        unsigned long long int ulli;
    133131        if ( sscanf( ptr, "%llu", &ulli ) == EOF ) {}
    134132        return ulli;
    135 } // ato
    136 
     133}
    137134
    138135float ato( const char * ptr ) {
     
    140137        if ( sscanf( ptr, "%f", &f ) == EOF ) {}
    141138        return f;
    142 } // ato
    143 
     139}
    144140double ato( const char * ptr ) {
    145141        double d;
    146142        if ( sscanf( ptr, "%lf", &d ) == EOF ) {}
    147143        return d;
    148 } // ato
    149 
     144}
    150145long double ato( const char * ptr ) {
    151146        long double ld;
    152147        if ( sscanf( ptr, "%Lf", &ld ) == EOF ) {}
    153148        return ld;
    154 } // ato
    155 
     149}
    156150
    157151float _Complex ato( const char * ptr ) {
     
    159153        if ( sscanf( ptr, "%g%gi", &re, &im ) == EOF ) {}
    160154        return re + im * _Complex_I;
    161 } // ato
    162 
     155}
    163156double _Complex ato( const char * ptr ) {
    164157        double re, im;
    165158        if ( sscanf( ptr, "%lf%lfi", &re, &im ) == EOF ) {}
    166159        return re + im * _Complex_I;
    167 } // ato
    168 
     160}
    169161long double _Complex ato( const char * ptr ) {
    170162        long double re, im;
    171163        if ( sscanf( ptr, "%Lf%Lfi", &re, &im ) == EOF ) {}
    172164        return re + im * _Complex_I;
    173 } // ato
    174 
     165}
    175166
    176167int strto( const char * sptr, char ** eptr, int base ) {
    177168        return (int)strtol( sptr, eptr, base );
    178 } // strto
    179 
     169}
    180170unsigned int strto( const char * sptr, char ** eptr, int base ) {
    181171        return (unsigned int)strtoul( sptr, eptr, base );
    182 } // strto
    183 
     172}
    184173long int strto( const char * sptr, char ** eptr, int base ) {
    185174        return strtol( sptr, eptr, base );
    186 } // strto
    187 
     175}
    188176unsigned long int strto( const char * sptr, char ** eptr, int base ) {
    189177        return strtoul( sptr, eptr, base );
    190 } // strto
    191 
     178}
    192179long long int strto( const char * sptr, char ** eptr, int base ) {
    193180        return strtoll( sptr, eptr, base );
    194 } // strto
    195 
     181}
    196182unsigned long long int strto( const char * sptr, char ** eptr, int base ) {
    197183        return strtoull( sptr, eptr, base );
    198 } // strto
    199 
     184}
    200185
    201186float strto( const char * sptr, char ** eptr ) {
    202187        return strtof( sptr, eptr );
    203 } // strto
    204 
     188}
    205189double strto( const char * sptr, char ** eptr ) {
    206190        return strtod( sptr, eptr );
    207 } // strto
    208 
     191}
    209192long double strto( const char * sptr, char ** eptr ) {
    210193        return strtold( sptr, eptr );
    211 } // strto
    212 
     194}
    213195
    214196float _Complex strto( const char * sptr, char ** eptr ) {
     
    219201        if ( sptr == *eptr ) return 0.0;
    220202        return re + im * _Complex_I;
    221 } // strto
    222 
     203}
    223204double _Complex strto( const char * sptr, char ** eptr ) {
    224205        double re, im;
     
    228209        if ( sptr == *eptr ) return 0.0;
    229210        return re + im * _Complex_I;
    230 } // strto
    231 
     211}
    232212long double _Complex strto( const char * sptr, char ** eptr ) {
    233213        long double re, im;
     
    237217        if ( sptr == *eptr ) return 0.0;
    238218        return re + im * _Complex_I;
    239 } // strto
     219}
    240220
    241221//---------------------------------------
  • src/tests/.expect/concurrent/sched-int-wait.txt

    rfae2cf8 r65aca88  
    1 Starting
    2 Done
  • src/tests/.expect/rational.txt

    rfae2cf8 r65aca88  
    17173/1
    18184/3
     19conversion
     200.75
     210.142857142857143
     223.14159292035398
     233/4
     241/7
     25355/113
    1926decompose
    2027more tests
  • src/tests/Makefile.am

    rfae2cf8 r65aca88  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sun May 14 14:43:48 2017
    14 ## Update Count     : 42
     13## Last Modified On : Thu Feb 16 15:27:50 2017
     14## Update Count     : 41
    1515###############################################################################
    1616
     
    9090        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    9191
    92 gmp : gmp.c
    93         ${CC} ${CFLAGS} -lgmp ${<} -o ${@}
    94 
    9592memberCtors-ERR1: memberCtors.c
    9693        ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
  • src/tests/Makefile.in

    rfae2cf8 r65aca88  
    709709        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    710710
    711 gmp : gmp.c
    712         ${CC} ${CFLAGS} -lgmp ${<} -o ${@}
    713 
    714711memberCtors-ERR1: memberCtors.c
    715712        ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
  • src/tests/rational.c

    rfae2cf8 r65aca88  
    1010// Created On       : Mon Mar 28 08:43:12 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 14 18:10:28 2017
    13 // Update Count     : 57
     12// Last Modified On : Tue May  2 22:11:05 2017
     13// Update Count     : 41
    1414//
    1515
     16#include <limits>
    1617#include <rational>
    17 #include <limits>
    18 #include <stdlib>
    1918#include <fstream>
    20 
    21 // UNNECESSARY, FIX ME
    22 void ?{}( int * this ) { *this = 0; }
    23 void ?{}( int * this, zero_t ) { *this = 0; }
    24 void ?{}( int * this, one_t ) { *this = 1; }
    2519
    2620int main() {
    2721        sout | "constructor" | endl;
    28         Rational(int) a = { 3 }, b = { 4 }, c;
     22        Rational a = { 3 }, b = { 4 }, c;
    2923        sout | a | b | c | endl;
    30 
    31         a = (Rational(int)){ 4, 8 };
    32         b = (Rational(int)){ 5, 7 };
     24        a = (Rational){ 4, 8 };
     25        b = (Rational){ 5, 7 };
    3326        sout | a | b | endl;
    34         a = (Rational(int)){ -2, -3 };
    35         b = (Rational(int)){ 3, -2 };
     27        a = (Rational){ -2, -3 };
     28        b = (Rational){ 3, -2 };
    3629        sout | a | b | endl;
    37         a = (Rational(int)){ -2, 3 };
    38         b = (Rational(int)){ 3, 2 };
     30        a = (Rational){ -2, 3 };
     31        b = (Rational){ 3, 2 };
    3932        sout | a | b | endl;
    4033
    4134        sout | "logical" | endl;
    42         a = (Rational(int)){ -2 };
    43         b = (Rational(int)){ -3, 2 };
     35        a = (Rational){ -2 };
     36        b = (Rational){ -3, 2 };
    4437        sout | a | b | endl;
    4538//      sout | a == 1 | endl; // FIX ME
     
    5750        sout | a / b | endl;
    5851
    59 //      sout | "conversion" | endl;
    60 //      a = (Rational(int)){ 3, 4 };
    61 //      sout | widen( a ) | endl;
    62 //      a = (Rational(int)){ 1, 7 };
    63 //      sout | widen( a ) | endl;
    64 //      a = (Rational(int)){ 355, 113 };
    65 //      sout | widen( a ) | endl;
    66 //      sout | narrow( 0.75, 4 ) | endl;
    67 //      sout | narrow( 0.14285714285714, 16 ) | endl;
    68 //      sout | narrow( 3.14159265358979, 256 ) | endl;
     52        sout | "conversion" | endl;
     53        a = (Rational){ 3, 4 };
     54        sout | widen( a ) | endl;
     55        a = (Rational){ 1, 7 };
     56        sout | widen( a ) | endl;
     57        a = (Rational){ 355, 113 };
     58        sout | widen( a ) | endl;
     59        sout | narrow( 0.75, 4 ) | endl;
     60        sout | narrow( 0.14285714285714, 16 ) | endl;
     61        sout | narrow( 3.14159265358979, 256 ) | endl;
    6962
    7063        sout | "decompose" | endl;
    71         int n, d;
     64        RationalImpl n, d;
    7265//      [n, d] = a;
    7366//      sout | a | n | d | endl;
    7467
    7568        sout | "more tests" | endl;
    76         Rational(int) x = { 1, 2 }, y = { 2 };
     69        Rational x = { 1, 2 }, y = { 2 };
    7770        sout | x - y | endl;
    7871        sout | x > y | endl;
     
    8073        sout | y | denominator( y, -2 ) | y | endl;
    8174
    82         Rational(int) z = { 0, 5 };
     75        Rational z = { 0, 5 };
    8376        sout | z | endl;
    8477
    8578        sout | x | numerator( x, 0 ) | x | endl;
    8679
    87         x = (Rational(int)){ 1, MAX } + (Rational(int)){ 1, MAX };
     80        x = (Rational){ 1, MAX } + (Rational){ 1, MAX };
    8881        sout | x | endl;
    89         x = (Rational(int)){ 3, MAX } + (Rational(int)){ 2, MAX };
     82        x = (Rational){ 3, MAX } + (Rational){ 2, MAX };
    9083        sout | x | endl;
    9184
  • src/tests/sched-int-wait.c

    rfae2cf8 r65aca88  
    113113        waiter_left = 4;
    114114        processor p;
    115         sout | "Starting" | endl;
    116115        {
    117116                Signaler  e;
     
    123122                }
    124123        }
    125         sout | "Done" | endl;
    126124}
Note: See TracChangeset for help on using the changeset viewer.