Changeset d36c117


Ignore:
Timestamp:
May 15, 2017, 12:04:49 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
9c951e3
Parents:
ce8c12f (diff), fae2cf8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into references

Files:
11 added
20 edited

Legend:

Unmodified
Added
Removed
  • Jenkins/FullBuild

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

    rce8c12f rd36c117  
    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

    rce8c12f rd36c117  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Tue Apr 18 17:16:13 2017
    14 %% Update Count     : 270
     13%% Last Modified On : Sun May 14 18:17:09 2017
     14%% Update Count     : 295
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    3636% Names used in the document.
    3737
    38 \newcommand{\CFA}{C$\mathbf\forall$\xspace} % Cforall symbolic name
     38\newcommand{\CFA}{C\raisebox{\depth}{\rotatebox{180}{\textscale{1.05}{\textsf{A}}}}\xspace} % Cforall symbolic name
    3939\newcommand{\CFL}{Cforall\xspace} % Cforall symbolic name
     40\newcommand{\Celeven}{C11\xspace} % C11 symbolic name
    4041\newcommand{\CC}{\rm C\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name
    4142\newcommand{\CCeleven}{\rm C\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name
     
    4344\newcommand{\CCseventeen}{\rm C\kern-.1em\hbox{+\kern-.25em+}17\xspace} % C++17 symbolic name
    4445\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}
    6970
    7071% reduce size of chapter/section titles
     
    9798\newcommand{\italic}[1]{\emph{\hyperpage{#1}}}
    9899\newcommand{\definition}[1]{\textbf{\hyperpage{#1}}}
    99 \newcommand{\see}[1]{\emph{see} #1}
     100\newcommand{\see}[1]{\emph{see}~#1}
    100101
    101102% Define some commands that produce formatted index entries suitable for cross-references.
     
    221222}%
    222223
    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 }%
     224\usepackage{lstlang}
    257225
    258226\newcommand{\CFADefaults}{%
     
    292260{}
    293261
    294 
    295262% Local Variables: %
    296263% tab-width: 4 %
  • doc/generic_types/generic_types.tex

    rce8c12f rd36c117  
    66\usepackage{upquote}                                                                    % switch curled `'" to straight
    77\usepackage{listings}                                                                   % format program code
     8\usepackage{rotating}
    89\usepackage[usenames]{color}
    910
     
    4849
    4950% Useful macros
    50 \newcommand{\CFA}{C$\mathbf\forall$\xspace} % Cforall symbolic name
     51\newcommand{\CFA}{C\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\hspace{-1pt}\xspace} % Cforall symbolic name
     52%\newcommand{\CFA}{C$\mathbf\forall$\xspace} % Cforall symbolic name
    5153\newcommand{\CC}{\rm C\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name
    5254\newcommand{\CCeleven}{\rm C\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name
     
    9799\acmJournal{PACMPL}
    98100
    99 \title{Generic and Tuple Types with Efficient Dynamic Layout in \CFA}
     101\title{Generic and Tuple Types with Efficient Dynamic Layout in \protect\CFA}
    100102
    101103\author{Aaron Moss}
     
    197199\label{sec:poly-fns}
    198200
    199 \CFA's polymorphism was originally formalized by \citet{Ditchfield92}, and first implemented by \citet{Bilson03}.
     201\CFA{}\hspace{1pt}'s polymorphism was originally formalized by \citet{Ditchfield92}, and first implemented by \citet{Bilson03}.
    200202The 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):
    201203\begin{lstlisting}
     
    950952}
    951953\end{lstlisting}
    952 \caption{\CFA Benchmark Test}
     954\caption{\protect\CFA Benchmark Test}
    953955\label{fig:BenchmarkTest}
    954956\end{figure}
     
    10201022While \CC provides good backwards compatibility with C, it has a steep learning curve for many of its extensions.
    10211023For example, polymorphism is provided via three disjoint mechanisms: overloading, inheritance, and templates.
    1022 The 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.
     1024The 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.
    10231025In 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.
    10241026The 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 100755 to 100644
  • doc/user/Makefile

    rce8c12f rd36c117  
    4747
    4848${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \
    49                 ../LaTeXmacros/common.tex ../LaTeXmacros/indexstyle ../bibliography/cfa.bib
     49                ../LaTeXmacros/common.tex ../LaTeXmacros/lstlang.sty ../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

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

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

    rce8c12f rd36c117  
    183183        containers/vector concurrency/coroutine concurrency/thread \
    184184        concurrency/kernel concurrency/monitor ${shell echo stdhdr/*} \
    185         concurrency/invoke.h
     185        gmp 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} concurrency/invoke.h
     326nobase_cfa_include_HEADERS = ${headers} ${stdhdr} gmp concurrency/invoke.h
    327327CLEANFILES = libcfa-prelude.c
    328328all: all-am
  • src/libcfa/iostream.c

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

    rce8c12f rd36c117  
    1212// Created On       : Wed Apr  6 17:56:25 2016
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Mon May  1 08:25:06 2017
    15 // Update Count     : 33
     14// Last Modified On : Sun May 14 16:49:13 2017
     15// Update Count     : 78
    1616//
    1717
     
    2121#include "iostream"
    2222
     23trait scalar( otype T ) {
     24};
     25
     26trait 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
    2347// implementation
    24 typedef long int RationalImpl;
     48
     49forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    2550struct Rational {
    26         RationalImpl numerator, denominator;                                    // invariant: denominator > 0
     51        RationalImpl numerator, denominator;                            // invariant: denominator > 0
    2752}; // Rational
    2853
    29 // constants
    30 extern struct Rational 0;
    31 extern struct Rational 1;
     54// constructors
    3255
    33 // constructors
    34 void ?{}( Rational * r );
    35 void ?{}( Rational * r, RationalImpl n );
    36 void ?{}( Rational * r, RationalImpl n, RationalImpl d );
     56forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     57void ?{}( Rational(RationalImpl) * r );
     58
     59forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     60void ?{}( Rational(RationalImpl) * r, RationalImpl n );
     61
     62forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     63void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d );
     64
     65forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     66void ?{}( Rational(RationalImpl) * r, zero_t );
     67
     68forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     69void ?{}( Rational(RationalImpl) * r, one_t );
    3770
    3871// getter for numerator/denominator
    39 RationalImpl numerator( Rational r );
    40 RationalImpl denominator( Rational r );
    41 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational src );
     72
     73forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     74RationalImpl numerator( Rational(RationalImpl) r );
     75
     76forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     77RationalImpl denominator( Rational(RationalImpl) r );
     78forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     79[ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );
     80
    4281// setter for numerator/denominator
    43 RationalImpl numerator( Rational r, RationalImpl n );
    44 RationalImpl denominator( Rational r, RationalImpl d );
     82
     83forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     84RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n );
     85
     86forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     87RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d );
    4588
    4689// comparison
    47 int ?==?( Rational l, Rational r );
    48 int ?!=?( Rational l, Rational r );
    49 int ?<?( Rational l, Rational r );
    50 int ?<=?( Rational l, Rational r );
    51 int ?>?( Rational l, Rational r );
    52 int ?>=?( Rational l, Rational r );
     90
     91forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     92int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     93
     94forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     95int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     96
     97forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     98int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     99
     100forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     101int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     102
     103forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     104int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     105
     106forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     107int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    53108
    54109// arithmetic
    55 Rational -?( Rational r );
    56 Rational ?+?( Rational l, Rational r );
    57 Rational ?-?( Rational l, Rational r );
    58 Rational ?*?( Rational l, Rational r );
    59 Rational ?/?( Rational l, Rational r );
     110
     111forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     112Rational(RationalImpl) +?( Rational(RationalImpl) r );
     113
     114forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     115Rational(RationalImpl) -?( Rational(RationalImpl) r );
     116
     117forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     118Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     119
     120forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     121Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     122
     123forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     124Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r );
     125
     126forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     127Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    60128
    61129// conversion
    62 double widen( Rational r );
    63 Rational narrow( double f, RationalImpl md );
     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 );
    64134
    65135// I/O
    66 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, Rational * );
    67 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, Rational );
     136forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     137forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
     138istype * ?|?( istype *, Rational(RationalImpl) * );
     139
     140forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     141forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
     142ostype * ?|?( ostype *, Rational(RationalImpl ) );
    68143
    69144#endif // RATIONAL_H
  • src/libcfa/rational.c

    rce8c12f rd36c117  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Apr 27 17:05:06 2017
    13 // Update Count     : 51
     12// Last Modified On : Sun May 14 17:25:19 2017
     13// Update Count     : 131
    1414//
    1515
     
    1717#include "fstream"
    1818#include "stdlib"
    19 #include "math"                                                                                 // floor
    20 
    21 
    22 // constants
    23 
    24 struct Rational 0 = {0, 1};
    25 struct Rational 1 = {1, 1};
    26 
    2719
    2820// helper routines
     
    3022// Calculate greatest common denominator of two numbers, the first of which may be negative. Used to reduce rationals.
    3123// alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm
     24forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    3225static RationalImpl gcd( RationalImpl a, RationalImpl b ) {
    3326        for ( ;; ) {                                                                            // Euclid's algorithm
    3427                RationalImpl r = a % b;
    35           if ( r == 0 ) break;
     28          if ( r == (RationalImpl){0} ) break;
    3629                a = b;
    3730                b = r;
     
    4033} // gcd
    4134
    42 static RationalImpl simplify( RationalImpl *n, RationalImpl *d ) {
    43         if ( *d == 0 ) {
     35forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     36static RationalImpl simplify( RationalImpl * n, RationalImpl * d ) {
     37        if ( *d == (RationalImpl){0} ) {
    4438                serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl;
    4539                exit( EXIT_FAILURE );
    4640        } // exit
    47         if ( *d < 0 ) { *d = -*d; *n = -*n; }                           // move sign to numerator
     41        if ( *d < (RationalImpl){0} ) { *d = -*d; *n = -*n; } // move sign to numerator
    4842        return gcd( abs( *n ), *d );                                            // simplify
    4943} // Rationalnumber::simplify
     
    5246// constructors
    5347
    54 void ?{}( Rational * r ) {
    55         r{ 0, 1 };
     48forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     49void ?{}( Rational(RationalImpl) * r ) {
     50        r{ (RationalImpl){0}, (RationalImpl){1} };
    5651} // rational
    5752
    58 void ?{}( Rational * r, RationalImpl n ) {
    59         r{ n, 1 };
     53forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     54void ?{}( Rational(RationalImpl) * r, RationalImpl n ) {
     55        r{ n, (RationalImpl){1} };
    6056} // rational
    6157
    62 void ?{}( Rational * r, RationalImpl n, RationalImpl d ) {
     58forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     59void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d ) {
    6360        RationalImpl t = simplify( &n, &d );                            // simplify
    6461        r->numerator = n / t;
     
    6966// getter for numerator/denominator
    7067
    71 RationalImpl numerator( Rational r ) {
     68forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     69RationalImpl numerator( Rational(RationalImpl) r ) {
    7270        return r.numerator;
    7371} // numerator
    7472
    75 RationalImpl denominator( Rational r ) {
     73forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     74RationalImpl denominator( Rational(RationalImpl) r ) {
    7675        return r.denominator;
    7776} // denominator
    7877
    79 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational src ) {
     78forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     79[ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) {
    8080        return *dest = src.[ numerator, denominator ];
    8181}
     
    8383// setter for numerator/denominator
    8484
    85 RationalImpl numerator( Rational r, RationalImpl n ) {
     85forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     86RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n ) {
    8687        RationalImpl prev = r.numerator;
    8788        RationalImpl t = gcd( abs( n ), r.denominator );                // simplify
     
    9192} // numerator
    9293
    93 RationalImpl denominator( Rational r, RationalImpl d ) {
     94forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     95RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ) {
    9496        RationalImpl prev = r.denominator;
    9597        RationalImpl t = simplify( &r.numerator, &d );                  // simplify
     
    102104// comparison
    103105
    104 int ?==?( Rational l, Rational r ) {
     106forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     107int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    105108        return l.numerator * r.denominator == l.denominator * r.numerator;
    106109} // ?==?
    107110
    108 int ?!=?( Rational l, Rational r ) {
     111forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     112int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    109113        return ! ( l == r );
    110114} // ?!=?
    111115
    112 int ?<?( Rational l, Rational r ) {
     116forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     117int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    113118        return l.numerator * r.denominator < l.denominator * r.numerator;
    114119} // ?<?
    115120
    116 int ?<=?( Rational l, Rational r ) {
    117         return l < r || l == r;
     121forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     122int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
     123        return l.numerator * r.denominator <= l.denominator * r.numerator;
    118124} // ?<=?
    119125
    120 int ?>?( Rational l, Rational r ) {
     126forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     127int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    121128        return ! ( l <= r );
    122129} // ?>?
    123130
    124 int ?>=?( Rational l, Rational r ) {
     131forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     132int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    125133        return ! ( l < r );
    126134} // ?>=?
     
    129137// arithmetic
    130138
    131 Rational -?( Rational r ) {
    132         Rational t = { -r.numerator, r.denominator };
     139forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     140Rational(RationalImpl) +?( Rational(RationalImpl) r ) {
     141        Rational(RationalImpl) t = { r.numerator, r.denominator };
     142        return t;
     143} // +?
     144
     145forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     146Rational(RationalImpl) -?( Rational(RationalImpl) r ) {
     147        Rational(RationalImpl) t = { -r.numerator, r.denominator };
    133148        return t;
    134149} // -?
    135150
    136 Rational ?+?( Rational l, Rational r ) {
     151forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     152Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    137153        if ( l.denominator == r.denominator ) {                         // special case
    138                 Rational t = { l.numerator + r.numerator, l.denominator };
     154                Rational(RationalImpl) t = { l.numerator + r.numerator, l.denominator };
    139155                return t;
    140156        } else {
    141                 Rational t = { l.numerator * r.denominator + l.denominator * r.numerator, l.denominator * r.denominator };
     157                Rational(RationalImpl) t = { l.numerator * r.denominator + l.denominator * r.numerator, l.denominator * r.denominator };
    142158                return t;
    143159        } // if
    144160} // ?+?
    145161
    146 Rational ?-?( Rational l, Rational r ) {
     162forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     163Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    147164        if ( l.denominator == r.denominator ) {                         // special case
    148                 Rational t = { l.numerator - r.numerator, l.denominator };
     165                Rational(RationalImpl) t = { l.numerator - r.numerator, l.denominator };
    149166                return t;
    150167        } else {
    151                 Rational t = { l.numerator * r.denominator - l.denominator * r.numerator, l.denominator * r.denominator };
     168                Rational(RationalImpl) t = { l.numerator * r.denominator - l.denominator * r.numerator, l.denominator * r.denominator };
    152169                return t;
    153170        } // if
    154171} // ?-?
    155172
    156 Rational ?*?( Rational l, Rational r ) {
    157         Rational t = { l.numerator * r.numerator, l.denominator * r.denominator };
     173forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     174Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
     175        Rational(RationalImpl) t = { l.numerator * r.numerator, l.denominator * r.denominator };
    158176        return t;
    159177} // ?*?
    160178
    161 Rational ?/?( Rational l, Rational r ) {
    162         if ( r.numerator < 0 ) {
     179forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     180Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
     181        if ( r.numerator < (RationalImpl){0} ) {
    163182                r.numerator = -r.numerator;
    164183                r.denominator = -r.denominator;
    165184        } // if
    166         Rational t = { l.numerator * r.denominator, l.denominator * r.numerator };
     185        Rational(RationalImpl) t = { l.numerator * r.denominator, l.denominator * r.numerator };
    167186        return t;
    168187} // ?/?
     
    171190// conversion
    172191
    173 double widen( Rational r ) {
    174         return (double)r.numerator / (double)r.denominator;
    175 } // widen
    176 
    177 // http://www.ics.uci.edu/~eppstein/numth/frap.c
    178 Rational 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
     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
    204225
    205226
    206227// I/O
    207228
    208 forall( dtype istype | istream( istype ) )
    209 istype * ?|?( istype *is, Rational *r ) {
     229forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     230forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
     231istype * ?|?( istype * is, Rational(RationalImpl) * r ) {
    210232        RationalImpl t;
    211233        is | &(r->numerator) | &(r->denominator);
     
    216238} // ?|?
    217239
    218 forall( dtype ostype | ostream( ostype ) )
    219 ostype * ?|?( ostype *os, Rational r ) {
     240forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     241forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
     242ostype * ?|?( ostype * os, Rational(RationalImpl ) r ) {
    220243        return os | r.numerator | '/' | r.denominator;
    221244} // ?|?
  • src/libcfa/stdlib

    rce8c12f rd36c117  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr  1 17:35:24 2017
    13 // Update Count     : 104
     12// Last Modified On : Tue May  9 08:42:44 2017
     13// Update Count     : 107
    1414//
    1515
     
    8484forall( otype T | { int ?<?( T, T ); } )
    8585T * bsearch( T key, const T * arr, size_t dimension );
     86
    8687forall( otype T | { int ?<?( T, T ); } )
    8788unsigned int bsearch( T key, const T * arr, size_t dimension );
     89
    8890
    8991forall( otype T | { int ?<?( T, T ); } )
     
    107109double abs( double _Complex );
    108110long double abs( long double _Complex );
     111forall ( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } )
     112T abs( T );
    109113
    110114//---------------------------------------
  • src/libcfa/stdlib.c

    rce8c12f rd36c117  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Apr 16 10:41:05 2017
    13 // Update Count     : 189
     12// Last Modified On : Tue May  9 08:43:00 2017
     13// Update Count     : 191
    1414//
    1515
     
    2727} // extern "C"
    2828
    29 forall( dtype T | sized(T) ) T * malloc( void ) {
    30         //printf( "malloc1\n" );
    31     return (T *)(void*)malloc( (size_t)sizeof(T) );
     29forall( dtype T | sized(T) ) T * malloc( void ) {               // type-safe
     30    return (T *)(void *)malloc( (size_t)sizeof(T) );
    3231} // malloc
    33 forall( dtype T | sized(T) ) T * malloc( char fill ) {
    34         //printf( "malloc3\n" );
    35         T * ptr = (T *)(void*)malloc( (size_t)sizeof(T) );
     32
     33forall( dtype T | sized(T) ) T * malloc( char fill ) {  // initial with fill value (like calloc)
     34        T * ptr = (T *)(void *)malloc( (size_t)sizeof(T) );
    3635    return memset( ptr, (int)fill, sizeof(T) );
    3736} // malloc
    3837
    39 forall( dtype T | sized(T) ) T * calloc( size_t nmemb ) {
    40         //printf( "calloc\n" );
     38forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size ) { // alternative realloc
     39    return (T *)realloc( ptr, size );
     40} // malloc
     41
     42forall( 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
     47forall( dtype T | sized(T) ) T * calloc( size_t nmemb ) { // type-safe array initialization with fill 0
    4148    return (T *)calloc( nmemb, sizeof(T) );
    4249} // calloc
    4350
    44 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) {
    45         //printf( "realloc1\n" );
     51
     52forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) { // type-safe
    4653    return (T *)(void *)realloc( (void *)ptr, size );
    4754} // realloc
    48 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) {
    49         //printf( "realloc2\n" );
     55
     56forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) { // alternative realloc with fill value
    5057    char * nptr = (T *)(void *)realloc( (void *)ptr, size );
    5158    size_t unused = malloc_usable_size( nptr );
     
    5461} // realloc
    5562
    56 forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size ) {
    57         //printf( "malloc4\n" );
    58     return (T *)realloc( ptr, size );
    59 } // malloc
    60 forall( 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 
    65 forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ) {
    66         //printf( "aligned_alloc\n" );
     63
     64forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ) { // aligned allocation
    6765    return (T *)memalign( alignment, sizeof(T) );
    6866} // aligned_alloc
    6967
    7068forall( dtype T | sized(T) ) T * memalign( size_t alignment ) {
    71         //printf( "memalign\n" );
    7269    return (T *)memalign( alignment, sizeof(T) );
    7370} // memalign
    7471
    7572forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment ) {
    76         //printf( "posix_memalign\n" );
    7773    return posix_memalign( (void **)ptr, alignment, sizeof(T) );
    7874} // posix_memalign
    7975
    80 forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } )
     76
     77forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } ) //  new
    8178T * new( Params p ) {
    8279        return ((T *)malloc()){ p };
    83 }
    84 
    85 forall( dtype T | { void ^?{}(T *); } )
     80} // new
     81
     82forall( dtype T | { void ^?{}(T *); } )                                 // delete
    8683void delete( T * ptr ) {
    87   if ( ptr ) {
    88     ^ptr{};
    89     free( ptr );
    90   }
    91 }
     84        if ( ptr ) {
     85                ^ptr{};
     86                free( ptr );
     87        }
     88} // delete
    9289
    9390forall( dtype T, ttype Params | { void ^?{}(T *); void delete(Params); } )
     
    9895        }
    9996        delete( rest );
    100 }
     97} // delete
    10198
    10299//---------------------------------------
     
    106103        if ( sscanf( ptr, "%d", &i ) == EOF ) {}
    107104        return i;
    108 }
     105} // ato
     106
    109107unsigned int ato( const char * ptr ) {
    110108        unsigned int ui;
    111109        if ( sscanf( ptr, "%u", &ui ) == EOF ) {}
    112110        return ui;
    113 }
     111} // ato
     112
    114113long int ato( const char * ptr ) {
    115114        long int li;
    116115        if ( sscanf( ptr, "%ld", &li ) == EOF ) {}
    117116        return li;
    118 }
     117} // ato
     118
    119119unsigned long int ato( const char * ptr ) {
    120120        unsigned long int uli;
    121121        if ( sscanf( ptr, "%lu", &uli ) == EOF ) {}
    122122        return uli;
    123 }
     123} // ato
     124
    124125long long int ato( const char * ptr ) {
    125126        long long int lli;
    126127        if ( sscanf( ptr, "%lld", &lli ) == EOF ) {}
    127128        return lli;
    128 }
     129} // ato
     130
    129131unsigned long long int ato( const char * ptr ) {
    130132        unsigned long long int ulli;
    131133        if ( sscanf( ptr, "%llu", &ulli ) == EOF ) {}
    132134        return ulli;
    133 }
     135} // ato
     136
    134137
    135138float ato( const char * ptr ) {
     
    137140        if ( sscanf( ptr, "%f", &f ) == EOF ) {}
    138141        return f;
    139 }
     142} // ato
     143
    140144double ato( const char * ptr ) {
    141145        double d;
    142146        if ( sscanf( ptr, "%lf", &d ) == EOF ) {}
    143147        return d;
    144 }
     148} // ato
     149
    145150long double ato( const char * ptr ) {
    146151        long double ld;
    147152        if ( sscanf( ptr, "%Lf", &ld ) == EOF ) {}
    148153        return ld;
    149 }
     154} // ato
     155
    150156
    151157float _Complex ato( const char * ptr ) {
     
    153159        if ( sscanf( ptr, "%g%gi", &re, &im ) == EOF ) {}
    154160        return re + im * _Complex_I;
    155 }
     161} // ato
     162
    156163double _Complex ato( const char * ptr ) {
    157164        double re, im;
    158165        if ( sscanf( ptr, "%lf%lfi", &re, &im ) == EOF ) {}
    159166        return re + im * _Complex_I;
    160 }
     167} // ato
     168
    161169long double _Complex ato( const char * ptr ) {
    162170        long double re, im;
    163171        if ( sscanf( ptr, "%Lf%Lfi", &re, &im ) == EOF ) {}
    164172        return re + im * _Complex_I;
    165 }
     173} // ato
     174
    166175
    167176int strto( const char * sptr, char ** eptr, int base ) {
    168177        return (int)strtol( sptr, eptr, base );
    169 }
     178} // strto
     179
    170180unsigned int strto( const char * sptr, char ** eptr, int base ) {
    171181        return (unsigned int)strtoul( sptr, eptr, base );
    172 }
     182} // strto
     183
    173184long int strto( const char * sptr, char ** eptr, int base ) {
    174185        return strtol( sptr, eptr, base );
    175 }
     186} // strto
     187
    176188unsigned long int strto( const char * sptr, char ** eptr, int base ) {
    177189        return strtoul( sptr, eptr, base );
    178 }
     190} // strto
     191
    179192long long int strto( const char * sptr, char ** eptr, int base ) {
    180193        return strtoll( sptr, eptr, base );
    181 }
     194} // strto
     195
    182196unsigned long long int strto( const char * sptr, char ** eptr, int base ) {
    183197        return strtoull( sptr, eptr, base );
    184 }
     198} // strto
     199
    185200
    186201float strto( const char * sptr, char ** eptr ) {
    187202        return strtof( sptr, eptr );
    188 }
     203} // strto
     204
    189205double strto( const char * sptr, char ** eptr ) {
    190206        return strtod( sptr, eptr );
    191 }
     207} // strto
     208
    192209long double strto( const char * sptr, char ** eptr ) {
    193210        return strtold( sptr, eptr );
    194 }
     211} // strto
     212
    195213
    196214float _Complex strto( const char * sptr, char ** eptr ) {
     
    201219        if ( sptr == *eptr ) return 0.0;
    202220        return re + im * _Complex_I;
    203 }
     221} // strto
     222
    204223double _Complex strto( const char * sptr, char ** eptr ) {
    205224        double re, im;
     
    209228        if ( sptr == *eptr ) return 0.0;
    210229        return re + im * _Complex_I;
    211 }
     230} // strto
     231
    212232long double _Complex strto( const char * sptr, char ** eptr ) {
    213233        long double re, im;
     
    217237        if ( sptr == *eptr ) return 0.0;
    218238        return re + im * _Complex_I;
    219 }
     239} // strto
    220240
    221241//---------------------------------------
  • src/tests/.expect/concurrent/sched-int-wait.txt

    rce8c12f rd36c117  
     1Starting
     2Done
  • src/tests/.expect/rational.txt

    rce8c12f rd36c117  
    17173/1
    18184/3
    19 conversion
    20 0.75
    21 0.142857142857143
    22 3.14159292035398
    23 3/4
    24 1/7
    25 355/113
    2619decompose
    2720more tests
  • src/tests/Makefile.am

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

    rce8c12f rd36c117  
    709709        ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@}
    710710
     711gmp : gmp.c
     712        ${CC} ${CFLAGS} -lgmp ${<} -o ${@}
     713
    711714memberCtors-ERR1: memberCtors.c
    712715        ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
  • src/tests/rational.c

    rce8c12f rd36c117  
    1010// Created On       : Mon Mar 28 08:43:12 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May  2 22:11:05 2017
    13 // Update Count     : 41
     12// Last Modified On : Sun May 14 18:10:28 2017
     13// Update Count     : 57
    1414//
    1515
     16#include <rational>
    1617#include <limits>
    17 #include <rational>
     18#include <stdlib>
    1819#include <fstream>
     20
     21// UNNECESSARY, FIX ME
     22void ?{}( int * this ) { *this = 0; }
     23void ?{}( int * this, zero_t ) { *this = 0; }
     24void ?{}( int * this, one_t ) { *this = 1; }
    1925
    2026int main() {
    2127        sout | "constructor" | endl;
    22         Rational a = { 3 }, b = { 4 }, c;
     28        Rational(int) a = { 3 }, b = { 4 }, c;
    2329        sout | a | b | c | endl;
    24         a = (Rational){ 4, 8 };
    25         b = (Rational){ 5, 7 };
     30
     31        a = (Rational(int)){ 4, 8 };
     32        b = (Rational(int)){ 5, 7 };
    2633        sout | a | b | endl;
    27         a = (Rational){ -2, -3 };
    28         b = (Rational){ 3, -2 };
     34        a = (Rational(int)){ -2, -3 };
     35        b = (Rational(int)){ 3, -2 };
    2936        sout | a | b | endl;
    30         a = (Rational){ -2, 3 };
    31         b = (Rational){ 3, 2 };
     37        a = (Rational(int)){ -2, 3 };
     38        b = (Rational(int)){ 3, 2 };
    3239        sout | a | b | endl;
    3340
    3441        sout | "logical" | endl;
    35         a = (Rational){ -2 };
    36         b = (Rational){ -3, 2 };
     42        a = (Rational(int)){ -2 };
     43        b = (Rational(int)){ -3, 2 };
    3744        sout | a | b | endl;
    3845//      sout | a == 1 | endl; // FIX ME
     
    5057        sout | a / b | endl;
    5158
    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;
     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;
    6269
    6370        sout | "decompose" | endl;
    64         RationalImpl n, d;
     71        int n, d;
    6572//      [n, d] = a;
    6673//      sout | a | n | d | endl;
    6774
    6875        sout | "more tests" | endl;
    69         Rational x = { 1, 2 }, y = { 2 };
     76        Rational(int) x = { 1, 2 }, y = { 2 };
    7077        sout | x - y | endl;
    7178        sout | x > y | endl;
     
    7380        sout | y | denominator( y, -2 ) | y | endl;
    7481
    75         Rational z = { 0, 5 };
     82        Rational(int) z = { 0, 5 };
    7683        sout | z | endl;
    7784
    7885        sout | x | numerator( x, 0 ) | x | endl;
    7986
    80         x = (Rational){ 1, MAX } + (Rational){ 1, MAX };
     87        x = (Rational(int)){ 1, MAX } + (Rational(int)){ 1, MAX };
    8188        sout | x | endl;
    82         x = (Rational){ 3, MAX } + (Rational){ 2, MAX };
     89        x = (Rational(int)){ 3, MAX } + (Rational(int)){ 2, MAX };
    8390        sout | x | endl;
    8491
  • src/tests/sched-int-wait.c

    rce8c12f rd36c117  
    113113        waiter_left = 4;
    114114        processor p;
     115        sout | "Starting" | endl;
    115116        {
    116117                Signaler  e;
     
    122123                }
    123124        }
     125        sout | "Done" | endl;
    124126}
Note: See TracChangeset for help on using the changeset viewer.