Changes in / [fae2cf8:65aca88]
- Files:
-
- 11 deleted
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
Jenkins/FullBuild
rfae2cf8 r65aca88 161 161 """ 162 162 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" 164 164 165 165 //send email notification -
Jenkinsfile
rfae2cf8 r65aca88 153 153 do_sendemail = ! (pSilent == 'true') 154 154 155 echo """Compiler 156 Architecture 157 Arc Flags 158 Run All Tests 159 Run Benchmark 160 Build Documentation 161 Publish 162 Silent 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() } 163 163 """ 164 164 -
doc/LaTeXmacros/common.tex
rfae2cf8 r65aca88 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Sun May 14 18:17:09201714 %% Update Count : 2 9513 %% Last Modified On : Tue Apr 18 17:16:13 2017 14 %% Update Count : 270 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 36 36 % Names used in the document. 37 37 38 \newcommand{\CFA}{C \raisebox{\depth}{\rotatebox{180}{\textscale{1.05}{\textsf{A}}}}\xspace} % Cforall symbolic name38 \newcommand{\CFA}{C$\mathbf\forall$\xspace} % Cforall symbolic name 39 39 \newcommand{\CFL}{Cforall\xspace} % Cforall symbolic name 40 \newcommand{\Celeven}{C11\xspace} % C11 symbolic name41 40 \newcommand{\CC}{\rm C\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name 42 41 \newcommand{\CCeleven}{\rm C\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name … … 44 43 \newcommand{\CCseventeen}{\rm C\kern-.1em\hbox{+\kern-.25em+}17\xspace} % C++17 symbolic name 45 44 \newcommand{\CCtwenty}{\rm C\kern-.1em\hbox{+\kern-.25em+}20\xspace} % C++20 symbolic name 45 \newcommand{\Celeven}{C11\xspace} % C11 symbolic name 46 46 \newcommand{\Csharp}{C\raisebox{-0.7ex}{\Large$^\sharp$}\xspace} % C# symbolic name 47 47 … … 67 67 \usepackage{pslatex} % reduce size of san serif font 68 68 \usepackage{relsize} % must be after change to small or selects old size 69 \usepackage{rotating}70 69 71 70 % reduce size of chapter/section titles … … 98 97 \newcommand{\italic}[1]{\emph{\hyperpage{#1}}} 99 98 \newcommand{\definition}[1]{\textbf{\hyperpage{#1}}} 100 \newcommand{\see}[1]{\emph{see} ~#1}99 \newcommand{\see}[1]{\emph{see} #1} 101 100 102 101 % Define some commands that produce formatted index entries suitable for cross-references. … … 222 221 }% 223 222 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 }% 225 257 226 258 \newcommand{\CFADefaults}{% … … 260 292 {} 261 293 294 262 295 % Local Variables: % 263 296 % tab-width: 4 % -
doc/generic_types/generic_types.tex
rfae2cf8 r65aca88 6 6 \usepackage{upquote} % switch curled `'" to straight 7 7 \usepackage{listings} % format program code 8 \usepackage{rotating}9 8 \usepackage[usenames]{color} 10 9 … … 49 48 50 49 % 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 53 51 \newcommand{\CC}{\rm C\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name 54 52 \newcommand{\CCeleven}{\rm C\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name … … 99 97 \acmJournal{PACMPL} 100 98 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} 102 100 103 101 \author{Aaron Moss} … … 199 197 \label{sec:poly-fns} 200 198 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}. 202 200 The 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): 203 201 \begin{lstlisting} … … 952 950 } 953 951 \end{lstlisting} 954 \caption{\ protect\CFA Benchmark Test}952 \caption{\CFA Benchmark Test} 955 953 \label{fig:BenchmarkTest} 956 954 \end{figure} … … 1022 1020 While \CC provides good backwards compatibility with C, it has a steep learning curve for many of its extensions. 1023 1021 For example, polymorphism is provided via three disjoint mechanisms: overloading, inheritance, and templates. 1024 The overloading is restricted because resolution does not us ethe 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.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. 1025 1023 In 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. 1026 1024 The 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
to100755
-
Property mode
changed from
-
doc/user/Makefile
rfae2cf8 r65aca88 47 47 48 48 ${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \ 49 ../LaTeXmacros/common.tex ../LaTeXmacros/ lstlang.sty ../LaTeXmacros/indexstyle ../bibliography/cfa.bib49 ../LaTeXmacros/common.tex ../LaTeXmacros/indexstyle ../bibliography/cfa.bib 50 50 # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run. 51 51 if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi -
src/GenPoly/Box.cc
rfae2cf8 r65aca88 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat May 13 09:26:38201713 // Update Count : 3 4112 // Last Modified On : Fri Mar 17 09:06:37 2017 13 // Update Count : 339 14 14 // 15 15 … … 706 706 Type *concrete = env->lookup( typeInst->get_name() ); 707 707 if ( concrete == 0 ) { 708 return typeInst;709 708 // 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 ); 712 711 } // if 713 712 return concrete; -
src/libcfa/Makefile.am
rfae2cf8 r65aca88 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : S un May 14 21:04:21201714 ## Update Count : 21 413 ## Last Modified On : Sat Mar 25 18:00:10 2017 14 ## Update Count : 212 15 15 ############################################################################### 16 16 … … 76 76 77 77 cfa_includedir = $(CFA_INCDIR) 78 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} gmpconcurrency/invoke.h78 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} concurrency/invoke.h 79 79 80 80 CLEANFILES = libcfa-prelude.c -
src/libcfa/Makefile.in
rfae2cf8 r65aca88 183 183 containers/vector concurrency/coroutine concurrency/thread \ 184 184 concurrency/kernel concurrency/monitor ${shell echo stdhdr/*} \ 185 gmpconcurrency/invoke.h185 concurrency/invoke.h 186 186 HEADERS = $(nobase_cfa_include_HEADERS) 187 187 ETAGS = etags … … 324 324 stdhdr = ${shell echo stdhdr/*} 325 325 cfa_includedir = $(CFA_INCDIR) 326 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} gmpconcurrency/invoke.h326 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} concurrency/invoke.h 327 327 CLEANFILES = libcfa-prelude.c 328 328 all: all-am -
src/libcfa/iostream.c
rfae2cf8 r65aca88 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 8 18:24:23201713 // Update Count : 36 912 // Last Modified On : Thu Mar 23 08:20:40 2017 13 // Update Count : 367 14 14 // 15 15 … … 160 160 [(unsigned char)'¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open, 161 161 // closing delimiters, no space before 162 [','] : Close, ['.'] : Close, [' ;'] : Close, ['!'] : Close, ['?'] : Close,162 [','] : Close, ['.'] : Close, [':'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close, 163 163 ['%'] : Close, [(unsigned char)'¢'] : Close, [(unsigned char)'»'] : Close, 164 164 [')'] : Close, [']'] : Close, ['}'] : Close, 165 165 // opening-closing delimiters, no space before or after 166 ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose, [':'] : OpenClose,166 ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose, 167 167 [' '] : OpenClose, ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace 168 168 }; // mask -
src/libcfa/rational
rfae2cf8 r65aca88 12 12 // Created On : Wed Apr 6 17:56:25 2016 13 13 // Last Modified By : Peter A. Buhr 14 // Last Modified On : Sun May 14 16:49:13201715 // Update Count : 7814 // Last Modified On : Mon May 1 08:25:06 2017 15 // Update Count : 33 16 16 // 17 17 … … 21 21 #include "iostream" 22 22 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 47 23 // implementation 48 49 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 24 typedef long int RationalImpl; 50 25 struct Rational { 51 RationalImpl numerator, denominator; // invariant: denominator > 026 RationalImpl numerator, denominator; // invariant: denominator > 0 52 27 }; // Rational 53 28 29 // constants 30 extern struct Rational 0; 31 extern struct Rational 1; 32 54 33 // 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 ); 34 void ?{}( Rational * r ); 35 void ?{}( Rational * r, RationalImpl n ); 36 void ?{}( Rational * r, RationalImpl n, RationalImpl d ); 70 37 71 38 // 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 39 RationalImpl numerator( Rational r ); 40 RationalImpl denominator( Rational r ); 41 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational src ); 81 42 // 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 ); 43 RationalImpl numerator( Rational r, RationalImpl n ); 44 RationalImpl denominator( Rational r, RationalImpl d ); 88 45 89 46 // 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 ); 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 ); 108 53 109 54 // 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 ); 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 ); 128 60 129 61 // 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 ); 62 double widen( Rational r ); 63 Rational narrow( double f, RationalImpl md ); 134 64 135 65 // 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 ) ); 66 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, Rational * ); 67 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, Rational ); 143 68 144 69 #endif // RATIONAL_H -
src/libcfa/rational.c
rfae2cf8 r65aca88 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 14 17:25:19201713 // Update Count : 13112 // Last Modified On : Thu Apr 27 17:05:06 2017 13 // Update Count : 51 14 14 // 15 15 … … 17 17 #include "fstream" 18 18 #include "stdlib" 19 #include "math" // floor 20 21 22 // constants 23 24 struct Rational 0 = {0, 1}; 25 struct Rational 1 = {1, 1}; 26 19 27 20 28 // helper routines … … 22 30 // Calculate greatest common denominator of two numbers, the first of which may be negative. Used to reduce rationals. 23 31 // alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm 24 forall ( otype RationalImpl | arithmetic( RationalImpl ) )25 32 static RationalImpl gcd( RationalImpl a, RationalImpl b ) { 26 33 for ( ;; ) { // Euclid's algorithm 27 34 RationalImpl r = a % b; 28 if ( r == (RationalImpl){0}) break;35 if ( r == 0 ) break; 29 36 a = b; 30 37 b = r; … … 33 40 } // gcd 34 41 35 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 36 static RationalImpl simplify( RationalImpl * n, RationalImpl * d ) { 37 if ( *d == (RationalImpl){0} ) { 42 static RationalImpl simplify( RationalImpl *n, RationalImpl *d ) { 43 if ( *d == 0 ) { 38 44 serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl; 39 45 exit( EXIT_FAILURE ); 40 46 } // exit 41 if ( *d < (RationalImpl){0} ) { *d = -*d; *n = -*n; }// move sign to numerator47 if ( *d < 0 ) { *d = -*d; *n = -*n; } // move sign to numerator 42 48 return gcd( abs( *n ), *d ); // simplify 43 49 } // Rationalnumber::simplify … … 46 52 // constructors 47 53 48 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 49 void ?{}( Rational(RationalImpl) * r ) { 50 r{ (RationalImpl){0}, (RationalImpl){1} }; 54 void ?{}( Rational * r ) { 55 r{ 0, 1 }; 51 56 } // rational 52 57 53 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 54 void ?{}( Rational(RationalImpl) * r, RationalImpl n ) { 55 r{ n, (RationalImpl){1} }; 58 void ?{}( Rational * r, RationalImpl n ) { 59 r{ n, 1 }; 56 60 } // rational 57 61 58 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 59 void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d ) { 62 void ?{}( Rational * r, RationalImpl n, RationalImpl d ) { 60 63 RationalImpl t = simplify( &n, &d ); // simplify 61 64 r->numerator = n / t; … … 66 69 // getter for numerator/denominator 67 70 68 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 69 RationalImpl numerator( Rational(RationalImpl) r ) { 71 RationalImpl numerator( Rational r ) { 70 72 return r.numerator; 71 73 } // numerator 72 74 73 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 74 RationalImpl denominator( Rational(RationalImpl) r ) { 75 RationalImpl denominator( Rational r ) { 75 76 return r.denominator; 76 77 } // denominator 77 78 78 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 79 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) { 79 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational src ) { 80 80 return *dest = src.[ numerator, denominator ]; 81 81 } … … 83 83 // setter for numerator/denominator 84 84 85 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 86 RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n ) { 85 RationalImpl numerator( Rational r, RationalImpl n ) { 87 86 RationalImpl prev = r.numerator; 88 87 RationalImpl t = gcd( abs( n ), r.denominator ); // simplify … … 92 91 } // numerator 93 92 94 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 95 RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ) { 93 RationalImpl denominator( Rational r, RationalImpl d ) { 96 94 RationalImpl prev = r.denominator; 97 95 RationalImpl t = simplify( &r.numerator, &d ); // simplify … … 104 102 // comparison 105 103 106 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 107 int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 104 int ?==?( Rational l, Rational r ) { 108 105 return l.numerator * r.denominator == l.denominator * r.numerator; 109 106 } // ?==? 110 107 111 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 112 int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 108 int ?!=?( Rational l, Rational r ) { 113 109 return ! ( l == r ); 114 110 } // ?!=? 115 111 116 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 117 int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 112 int ?<?( Rational l, Rational r ) { 118 113 return l.numerator * r.denominator < l.denominator * r.numerator; 119 114 } // ?<? 120 115 121 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 122 int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 123 return l.numerator * r.denominator <= l.denominator * r.numerator; 116 int ?<=?( Rational l, Rational r ) { 117 return l < r || l == r; 124 118 } // ?<=? 125 119 126 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 127 int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 120 int ?>?( Rational l, Rational r ) { 128 121 return ! ( l <= r ); 129 122 } // ?>? 130 123 131 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 132 int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 124 int ?>=?( Rational l, Rational r ) { 133 125 return ! ( l < r ); 134 126 } // ?>=? … … 137 129 // arithmetic 138 130 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 }; 131 Rational -?( Rational r ) { 132 Rational t = { -r.numerator, r.denominator }; 148 133 return t; 149 134 } // -? 150 135 151 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 152 Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 136 Rational ?+?( Rational l, Rational r ) { 153 137 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 }; 155 139 return t; 156 140 } 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 }; 158 142 return t; 159 143 } // if 160 144 } // ?+? 161 145 162 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 163 Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 146 Rational ?-?( Rational l, Rational r ) { 164 147 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 }; 166 149 return t; 167 150 } 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 }; 169 152 return t; 170 153 } // if 171 154 } // ?-? 172 155 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 }; 156 Rational ?*?( Rational l, Rational r ) { 157 Rational t = { l.numerator * r.numerator, l.denominator * r.denominator }; 176 158 return t; 177 159 } // ?*? 178 160 179 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 180 Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 181 if ( r.numerator < (RationalImpl){0} ) { 161 Rational ?/?( Rational l, Rational r ) { 162 if ( r.numerator < 0 ) { 182 163 r.numerator = -r.numerator; 183 164 r.denominator = -r.denominator; 184 165 } // if 185 Rational (RationalImpl)t = { l.numerator * r.denominator, l.denominator * r.numerator };166 Rational t = { l.numerator * r.denominator, l.denominator * r.numerator }; 186 167 return t; 187 168 } // ?/? … … 190 171 // conversion 191 172 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 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 225 204 226 205 227 206 // I/O 228 207 229 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 230 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } ) 231 istype * ?|?( istype * is, Rational(RationalImpl) * r ) { 208 forall( dtype istype | istream( istype ) ) 209 istype * ?|?( istype *is, Rational *r ) { 232 210 RationalImpl t; 233 211 is | &(r->numerator) | &(r->denominator); … … 238 216 } // ?|? 239 217 240 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 241 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } ) 242 ostype * ?|?( ostype * os, Rational(RationalImpl ) r ) { 218 forall( dtype ostype | ostream( ostype ) ) 219 ostype * ?|?( ostype *os, Rational r ) { 243 220 return os | r.numerator | '/' | r.denominator; 244 221 } // ?|? -
src/libcfa/stdlib
rfae2cf8 r65aca88 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 9 08:42:44 201713 // Update Count : 10 712 // Last Modified On : Sat Apr 1 17:35:24 2017 13 // Update Count : 104 14 14 // 15 15 … … 84 84 forall( otype T | { int ?<?( T, T ); } ) 85 85 T * bsearch( T key, const T * arr, size_t dimension ); 86 87 86 forall( otype T | { int ?<?( T, T ); } ) 88 87 unsigned int bsearch( T key, const T * arr, size_t dimension ); 89 90 88 91 89 forall( otype T | { int ?<?( T, T ); } ) … … 109 107 double abs( double _Complex ); 110 108 long double abs( long double _Complex ); 111 forall ( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } )112 T abs( T );113 109 114 110 //--------------------------------------- -
src/libcfa/stdlib.c
rfae2cf8 r65aca88 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 9 08:43:00201713 // Update Count : 1 9112 // Last Modified On : Sun Apr 16 10:41:05 2017 13 // Update Count : 189 14 14 // 15 15 … … 27 27 } // extern "C" 28 28 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) ); 29 forall( dtype T | sized(T) ) T * malloc( void ) { 30 //printf( "malloc1\n" ); 31 return (T *)(void*)malloc( (size_t)sizeof(T) ); 32 } // 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) ); 35 36 return memset( ptr, (int)fill, sizeof(T) ); 36 37 } // malloc 37 38 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 39 forall( dtype T | sized(T) ) T * calloc( size_t nmemb ) { 40 //printf( "calloc\n" ); 48 41 return (T *)calloc( nmemb, sizeof(T) ); 49 42 } // calloc 50 43 51 52 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) { // type-safe 44 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) { 45 //printf( "realloc1\n" ); 53 46 return (T *)(void *)realloc( (void *)ptr, size ); 54 47 } // realloc 55 56 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) { // alternative realloc with fill value 48 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) { 49 //printf( "realloc2\n" ); 57 50 char * nptr = (T *)(void *)realloc( (void *)ptr, size ); 58 51 size_t unused = malloc_usable_size( nptr ); … … 61 54 } // realloc 62 55 63 64 forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ) { // aligned allocation 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" ); 65 67 return (T *)memalign( alignment, sizeof(T) ); 66 68 } // aligned_alloc 67 69 68 70 forall( dtype T | sized(T) ) T * memalign( size_t alignment ) { 71 //printf( "memalign\n" ); 69 72 return (T *)memalign( alignment, sizeof(T) ); 70 73 } // memalign 71 74 72 75 forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment ) { 76 //printf( "posix_memalign\n" ); 73 77 return posix_memalign( (void **)ptr, alignment, sizeof(T) ); 74 78 } // posix_memalign 75 79 76 77 forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } ) // new 80 forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } ) 78 81 T * new( Params p ) { 79 82 return ((T *)malloc()){ p }; 80 } // new81 82 forall( dtype T | { void ^?{}(T *); } ) // delete83 } 84 85 forall( dtype T | { void ^?{}(T *); } ) 83 86 void delete( T * ptr ) { 84 85 86 87 88 } // delete87 if ( ptr ) { 88 ^ptr{}; 89 free( ptr ); 90 } 91 } 89 92 90 93 forall( dtype T, ttype Params | { void ^?{}(T *); void delete(Params); } ) … … 95 98 } 96 99 delete( rest ); 97 } // delete100 } 98 101 99 102 //--------------------------------------- … … 103 106 if ( sscanf( ptr, "%d", &i ) == EOF ) {} 104 107 return i; 105 } // ato 106 108 } 107 109 unsigned int ato( const char * ptr ) { 108 110 unsigned int ui; 109 111 if ( sscanf( ptr, "%u", &ui ) == EOF ) {} 110 112 return ui; 111 } // ato 112 113 } 113 114 long int ato( const char * ptr ) { 114 115 long int li; 115 116 if ( sscanf( ptr, "%ld", &li ) == EOF ) {} 116 117 return li; 117 } // ato 118 118 } 119 119 unsigned long int ato( const char * ptr ) { 120 120 unsigned long int uli; 121 121 if ( sscanf( ptr, "%lu", &uli ) == EOF ) {} 122 122 return uli; 123 } // ato 124 123 } 125 124 long long int ato( const char * ptr ) { 126 125 long long int lli; 127 126 if ( sscanf( ptr, "%lld", &lli ) == EOF ) {} 128 127 return lli; 129 } // ato 130 128 } 131 129 unsigned long long int ato( const char * ptr ) { 132 130 unsigned long long int ulli; 133 131 if ( sscanf( ptr, "%llu", &ulli ) == EOF ) {} 134 132 return ulli; 135 } // ato 136 133 } 137 134 138 135 float ato( const char * ptr ) { … … 140 137 if ( sscanf( ptr, "%f", &f ) == EOF ) {} 141 138 return f; 142 } // ato 143 139 } 144 140 double ato( const char * ptr ) { 145 141 double d; 146 142 if ( sscanf( ptr, "%lf", &d ) == EOF ) {} 147 143 return d; 148 } // ato 149 144 } 150 145 long double ato( const char * ptr ) { 151 146 long double ld; 152 147 if ( sscanf( ptr, "%Lf", &ld ) == EOF ) {} 153 148 return ld; 154 } // ato 155 149 } 156 150 157 151 float _Complex ato( const char * ptr ) { … … 159 153 if ( sscanf( ptr, "%g%gi", &re, &im ) == EOF ) {} 160 154 return re + im * _Complex_I; 161 } // ato 162 155 } 163 156 double _Complex ato( const char * ptr ) { 164 157 double re, im; 165 158 if ( sscanf( ptr, "%lf%lfi", &re, &im ) == EOF ) {} 166 159 return re + im * _Complex_I; 167 } // ato 168 160 } 169 161 long double _Complex ato( const char * ptr ) { 170 162 long double re, im; 171 163 if ( sscanf( ptr, "%Lf%Lfi", &re, &im ) == EOF ) {} 172 164 return re + im * _Complex_I; 173 } // ato 174 165 } 175 166 176 167 int strto( const char * sptr, char ** eptr, int base ) { 177 168 return (int)strtol( sptr, eptr, base ); 178 } // strto 179 169 } 180 170 unsigned int strto( const char * sptr, char ** eptr, int base ) { 181 171 return (unsigned int)strtoul( sptr, eptr, base ); 182 } // strto 183 172 } 184 173 long int strto( const char * sptr, char ** eptr, int base ) { 185 174 return strtol( sptr, eptr, base ); 186 } // strto 187 175 } 188 176 unsigned long int strto( const char * sptr, char ** eptr, int base ) { 189 177 return strtoul( sptr, eptr, base ); 190 } // strto 191 178 } 192 179 long long int strto( const char * sptr, char ** eptr, int base ) { 193 180 return strtoll( sptr, eptr, base ); 194 } // strto 195 181 } 196 182 unsigned long long int strto( const char * sptr, char ** eptr, int base ) { 197 183 return strtoull( sptr, eptr, base ); 198 } // strto 199 184 } 200 185 201 186 float strto( const char * sptr, char ** eptr ) { 202 187 return strtof( sptr, eptr ); 203 } // strto 204 188 } 205 189 double strto( const char * sptr, char ** eptr ) { 206 190 return strtod( sptr, eptr ); 207 } // strto 208 191 } 209 192 long double strto( const char * sptr, char ** eptr ) { 210 193 return strtold( sptr, eptr ); 211 } // strto 212 194 } 213 195 214 196 float _Complex strto( const char * sptr, char ** eptr ) { … … 219 201 if ( sptr == *eptr ) return 0.0; 220 202 return re + im * _Complex_I; 221 } // strto 222 203 } 223 204 double _Complex strto( const char * sptr, char ** eptr ) { 224 205 double re, im; … … 228 209 if ( sptr == *eptr ) return 0.0; 229 210 return re + im * _Complex_I; 230 } // strto 231 211 } 232 212 long double _Complex strto( const char * sptr, char ** eptr ) { 233 213 long double re, im; … … 237 217 if ( sptr == *eptr ) return 0.0; 238 218 return re + im * _Complex_I; 239 } // strto219 } 240 220 241 221 //--------------------------------------- -
src/tests/.expect/concurrent/sched-int-wait.txt
rfae2cf8 r65aca88 1 Starting2 Done -
src/tests/.expect/rational.txt
rfae2cf8 r65aca88 17 17 3/1 18 18 4/3 19 conversion 20 0.75 21 0.142857142857143 22 3.14159292035398 23 3/4 24 1/7 25 355/113 19 26 decompose 20 27 more tests -
src/tests/Makefile.am
rfae2cf8 r65aca88 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Sun May 14 14:43:48201714 ## Update Count : 4 213 ## Last Modified On : Thu Feb 16 15:27:50 2017 14 ## Update Count : 41 15 15 ############################################################################### 16 16 … … 90 90 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 91 91 92 gmp : gmp.c93 ${CC} ${CFLAGS} -lgmp ${<} -o ${@}94 95 92 memberCtors-ERR1: memberCtors.c 96 93 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} -
src/tests/Makefile.in
rfae2cf8 r65aca88 709 709 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 710 710 711 gmp : gmp.c712 ${CC} ${CFLAGS} -lgmp ${<} -o ${@}713 714 711 memberCtors-ERR1: memberCtors.c 715 712 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} -
src/tests/rational.c
rfae2cf8 r65aca88 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 14 18:10:28201713 // Update Count : 5712 // Last Modified On : Tue May 2 22:11:05 2017 13 // Update Count : 41 14 14 // 15 15 16 #include <limits> 16 17 #include <rational> 17 #include <limits>18 #include <stdlib>19 18 #include <fstream> 20 21 // UNNECESSARY, FIX ME22 void ?{}( int * this ) { *this = 0; }23 void ?{}( int * this, zero_t ) { *this = 0; }24 void ?{}( int * this, one_t ) { *this = 1; }25 19 26 20 int main() { 27 21 sout | "constructor" | endl; 28 Rational (int)a = { 3 }, b = { 4 }, c;22 Rational a = { 3 }, b = { 4 }, c; 29 23 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 }; 33 26 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 }; 36 29 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 }; 39 32 sout | a | b | endl; 40 33 41 34 sout | "logical" | endl; 42 a = (Rational (int)){ -2 };43 b = (Rational (int)){ -3, 2 };35 a = (Rational){ -2 }; 36 b = (Rational){ -3, 2 }; 44 37 sout | a | b | endl; 45 38 // sout | a == 1 | endl; // FIX ME … … 57 50 sout | a / b | endl; 58 51 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; 69 62 70 63 sout | "decompose" | endl; 71 intn, d;64 RationalImpl n, d; 72 65 // [n, d] = a; 73 66 // sout | a | n | d | endl; 74 67 75 68 sout | "more tests" | endl; 76 Rational (int)x = { 1, 2 }, y = { 2 };69 Rational x = { 1, 2 }, y = { 2 }; 77 70 sout | x - y | endl; 78 71 sout | x > y | endl; … … 80 73 sout | y | denominator( y, -2 ) | y | endl; 81 74 82 Rational (int)z = { 0, 5 };75 Rational z = { 0, 5 }; 83 76 sout | z | endl; 84 77 85 78 sout | x | numerator( x, 0 ) | x | endl; 86 79 87 x = (Rational (int)){ 1, MAX } + (Rational(int)){ 1, MAX };80 x = (Rational){ 1, MAX } + (Rational){ 1, MAX }; 88 81 sout | x | endl; 89 x = (Rational (int)){ 3, MAX } + (Rational(int)){ 2, MAX };82 x = (Rational){ 3, MAX } + (Rational){ 2, MAX }; 90 83 sout | x | endl; 91 84 -
src/tests/sched-int-wait.c
rfae2cf8 r65aca88 113 113 waiter_left = 4; 114 114 processor p; 115 sout | "Starting" | endl;116 115 { 117 116 Signaler e; … … 123 122 } 124 123 } 125 sout | "Done" | endl;126 124 }
Note:
See TracChangeset
for help on using the changeset viewer.