Changeset d36c117
- Timestamp:
- May 15, 2017, 12:04:49 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, 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. - Files:
-
- 11 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
Jenkins/FullBuild
rce8c12f rd36c117 161 161 """ 162 162 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" 164 164 165 165 //send email notification -
Jenkinsfile
rce8c12f rd36c117 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
rce8c12f rd36c117 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Tue Apr 18 17:16:13201714 %% Update Count : 2 7013 %% Last Modified On : Sun May 14 18:17:09 2017 14 %% Update Count : 295 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 36 36 % Names used in the document. 37 37 38 \newcommand{\CFA}{C $\mathbf\forall$\xspace} % Cforall symbolic name38 \newcommand{\CFA}{C\raisebox{\depth}{\rotatebox{180}{\textscale{1.05}{\textsf{A}}}}\xspace} % Cforall symbolic name 39 39 \newcommand{\CFL}{Cforall\xspace} % Cforall symbolic name 40 \newcommand{\Celeven}{C11\xspace} % C11 symbolic name 40 41 \newcommand{\CC}{\rm C\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name 41 42 \newcommand{\CCeleven}{\rm C\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name … … 43 44 \newcommand{\CCseventeen}{\rm C\kern-.1em\hbox{+\kern-.25em+}17\xspace} % C++17 symbolic name 44 45 \newcommand{\CCtwenty}{\rm C\kern-.1em\hbox{+\kern-.25em+}20\xspace} % C++20 symbolic name 45 \newcommand{\Celeven}{C11\xspace} % C11 symbolic name46 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} 69 70 70 71 % reduce size of chapter/section titles … … 97 98 \newcommand{\italic}[1]{\emph{\hyperpage{#1}}} 98 99 \newcommand{\definition}[1]{\textbf{\hyperpage{#1}}} 99 \newcommand{\see}[1]{\emph{see} 100 \newcommand{\see}[1]{\emph{see}~#1} 100 101 101 102 % Define some commands that produce formatted index entries suitable for cross-references. … … 221 222 }% 222 223 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} 257 225 258 226 \newcommand{\CFADefaults}{% … … 292 260 {} 293 261 294 295 262 % Local Variables: % 296 263 % tab-width: 4 % -
doc/generic_types/generic_types.tex
rce8c12f rd36c117 6 6 \usepackage{upquote} % switch curled `'" to straight 7 7 \usepackage{listings} % format program code 8 \usepackage{rotating} 8 9 \usepackage[usenames]{color} 9 10 … … 48 49 49 50 % 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 51 53 \newcommand{\CC}{\rm C\kern-.1em\hbox{+\kern-.25em+}\xspace} % C++ symbolic name 52 54 \newcommand{\CCeleven}{\rm C\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name … … 97 99 \acmJournal{PACMPL} 98 100 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} 100 102 101 103 \author{Aaron Moss} … … 197 199 \label{sec:poly-fns} 198 200 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}. 200 202 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): 201 203 \begin{lstlisting} … … 950 952 } 951 953 \end{lstlisting} 952 \caption{\ CFA Benchmark Test}954 \caption{\protect\CFA Benchmark Test} 953 955 \label{fig:BenchmarkTest} 954 956 \end{figure} … … 1020 1022 While \CC provides good backwards compatibility with C, it has a steep learning curve for many of its extensions. 1021 1023 For example, polymorphism is provided via three disjoint mechanisms: overloading, inheritance, and templates. 1022 The overloading is restricted because resolution does not us ingthe 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.1024 The overloading is restricted because resolution does not use the return type, inheritance requires learning object-oriented programming and coping with a restricted nominal-inheritance hierarchy, templates cannot be separately compiled resulting in compilation/code bloat and poor error messages, and determining how these mechanisms interact and which to use is confusing. 1023 1025 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. 1024 1026 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
100755
to100644
-
Property
mode
changed from
-
doc/user/Makefile
rce8c12f rd36c117 47 47 48 48 ${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \ 49 ../LaTeXmacros/common.tex ../LaTeXmacros/ indexstyle ../bibliography/cfa.bib49 ../LaTeXmacros/common.tex ../LaTeXmacros/lstlang.sty ../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
rce8c12f rd36c117 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:06:37201713 // Update Count : 3 3912 // Last Modified On : Sat May 13 09:26:38 2017 13 // Update Count : 341 14 14 // 15 15 … … 706 706 Type *concrete = env->lookup( typeInst->get_name() ); 707 707 if ( concrete == 0 ) { 708 return typeInst; 708 709 // 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 ); 711 712 } // if 712 713 return concrete; -
src/libcfa/Makefile.am
rce8c12f rd36c117 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : S at Mar 25 18:00:10201714 ## Update Count : 21 213 ## Last Modified On : Sun May 14 21:04:21 2017 14 ## Update Count : 214 15 15 ############################################################################### 16 16 … … 76 76 77 77 cfa_includedir = $(CFA_INCDIR) 78 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} concurrency/invoke.h78 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} gmp concurrency/invoke.h 79 79 80 80 CLEANFILES = libcfa-prelude.c -
src/libcfa/Makefile.in
rce8c12f rd36c117 183 183 containers/vector concurrency/coroutine concurrency/thread \ 184 184 concurrency/kernel concurrency/monitor ${shell echo stdhdr/*} \ 185 concurrency/invoke.h185 gmp 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} concurrency/invoke.h326 nobase_cfa_include_HEADERS = ${headers} ${stdhdr} gmp concurrency/invoke.h 327 327 CLEANFILES = libcfa-prelude.c 328 328 all: all-am -
src/libcfa/iostream.c
rce8c12f rd36c117 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 23 08:20:40201713 // Update Count : 36 712 // Last Modified On : Mon May 8 18:24:23 2017 13 // Update Count : 369 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, ['?'] : Close,162 [','] : 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, 166 ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose, [':'] : OpenClose, 167 167 [' '] : OpenClose, ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace 168 168 }; // mask -
src/libcfa/rational
rce8c12f rd36c117 12 12 // Created On : Wed Apr 6 17:56:25 2016 13 13 // Last Modified By : Peter A. Buhr 14 // Last Modified On : Mon May 1 08:25:06201715 // Update Count : 3314 // Last Modified On : Sun May 14 16:49:13 2017 15 // Update Count : 78 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 23 47 // implementation 24 typedef long int RationalImpl; 48 49 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 25 50 struct Rational { 26 RationalImpl numerator, denominator; 51 RationalImpl numerator, denominator; // invariant: denominator > 0 27 52 }; // Rational 28 53 29 // constants 30 extern struct Rational 0; 31 extern struct Rational 1; 54 // constructors 32 55 33 // constructors 34 void ?{}( Rational * r ); 35 void ?{}( Rational * r, RationalImpl n ); 36 void ?{}( Rational * r, RationalImpl n, RationalImpl d ); 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 ); 37 70 38 71 // getter for numerator/denominator 39 RationalImpl numerator( Rational r ); 40 RationalImpl denominator( Rational r ); 41 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational src ); 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 42 81 // setter for numerator/denominator 43 RationalImpl numerator( Rational r, RationalImpl n ); 44 RationalImpl denominator( Rational r, RationalImpl d ); 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 ); 45 88 46 89 // 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 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 ); 53 108 54 109 // 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 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 ); 60 128 61 129 // 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 ); 64 134 65 135 // I/O 66 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, Rational * ); 67 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, Rational ); 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 ) ); 68 143 69 144 #endif // RATIONAL_H -
src/libcfa/rational.c
rce8c12f rd36c117 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Apr 27 17:05:06201713 // Update Count : 5112 // Last Modified On : Sun May 14 17:25:19 2017 13 // Update Count : 131 14 14 // 15 15 … … 17 17 #include "fstream" 18 18 #include "stdlib" 19 #include "math" // floor20 21 22 // constants23 24 struct Rational 0 = {0, 1};25 struct Rational 1 = {1, 1};26 27 19 28 20 // helper routines … … 30 22 // Calculate greatest common denominator of two numbers, the first of which may be negative. Used to reduce rationals. 31 23 // alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm 24 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 32 25 static RationalImpl gcd( RationalImpl a, RationalImpl b ) { 33 26 for ( ;; ) { // Euclid's algorithm 34 27 RationalImpl r = a % b; 35 if ( r == 0) break;28 if ( r == (RationalImpl){0} ) break; 36 29 a = b; 37 30 b = r; … … 40 33 } // gcd 41 34 42 static RationalImpl simplify( RationalImpl *n, RationalImpl *d ) { 43 if ( *d == 0 ) { 35 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 36 static RationalImpl simplify( RationalImpl * n, RationalImpl * d ) { 37 if ( *d == (RationalImpl){0} ) { 44 38 serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl; 45 39 exit( EXIT_FAILURE ); 46 40 } // exit 47 if ( *d < 0 ) { *d = -*d; *n = -*n; }// move sign to numerator41 if ( *d < (RationalImpl){0} ) { *d = -*d; *n = -*n; } // move sign to numerator 48 42 return gcd( abs( *n ), *d ); // simplify 49 43 } // Rationalnumber::simplify … … 52 46 // constructors 53 47 54 void ?{}( Rational * r ) { 55 r{ 0, 1 }; 48 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 49 void ?{}( Rational(RationalImpl) * r ) { 50 r{ (RationalImpl){0}, (RationalImpl){1} }; 56 51 } // rational 57 52 58 void ?{}( Rational * r, RationalImpl n ) { 59 r{ n, 1 }; 53 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 54 void ?{}( Rational(RationalImpl) * r, RationalImpl n ) { 55 r{ n, (RationalImpl){1} }; 60 56 } // rational 61 57 62 void ?{}( Rational * r, RationalImpl n, RationalImpl d ) { 58 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 59 void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d ) { 63 60 RationalImpl t = simplify( &n, &d ); // simplify 64 61 r->numerator = n / t; … … 69 66 // getter for numerator/denominator 70 67 71 RationalImpl numerator( Rational r ) { 68 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 69 RationalImpl numerator( Rational(RationalImpl) r ) { 72 70 return r.numerator; 73 71 } // numerator 74 72 75 RationalImpl denominator( Rational r ) { 73 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 74 RationalImpl denominator( Rational(RationalImpl) r ) { 76 75 return r.denominator; 77 76 } // denominator 78 77 79 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational src ) { 78 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 79 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) { 80 80 return *dest = src.[ numerator, denominator ]; 81 81 } … … 83 83 // setter for numerator/denominator 84 84 85 RationalImpl numerator( Rational r, RationalImpl n ) { 85 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 86 RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n ) { 86 87 RationalImpl prev = r.numerator; 87 88 RationalImpl t = gcd( abs( n ), r.denominator ); // simplify … … 91 92 } // numerator 92 93 93 RationalImpl denominator( Rational r, RationalImpl d ) { 94 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 95 RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ) { 94 96 RationalImpl prev = r.denominator; 95 97 RationalImpl t = simplify( &r.numerator, &d ); // simplify … … 102 104 // comparison 103 105 104 int ?==?( Rational l, Rational r ) { 106 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 107 int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 105 108 return l.numerator * r.denominator == l.denominator * r.numerator; 106 109 } // ?==? 107 110 108 int ?!=?( Rational l, Rational r ) { 111 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 112 int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 109 113 return ! ( l == r ); 110 114 } // ?!=? 111 115 112 int ?<?( Rational l, Rational r ) { 116 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 117 int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 113 118 return l.numerator * r.denominator < l.denominator * r.numerator; 114 119 } // ?<? 115 120 116 int ?<=?( Rational l, Rational r ) { 117 return l < r || l == r; 121 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 122 int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 123 return l.numerator * r.denominator <= l.denominator * r.numerator; 118 124 } // ?<=? 119 125 120 int ?>?( Rational l, Rational r ) { 126 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 127 int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 121 128 return ! ( l <= r ); 122 129 } // ?>? 123 130 124 int ?>=?( Rational l, Rational r ) { 131 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 132 int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 125 133 return ! ( l < r ); 126 134 } // ?>=? … … 129 137 // arithmetic 130 138 131 Rational -?( Rational r ) { 132 Rational t = { -r.numerator, r.denominator }; 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 }; 133 148 return t; 134 149 } // -? 135 150 136 Rational ?+?( Rational l, Rational r ) { 151 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 152 Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 137 153 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 }; 139 155 return t; 140 156 } 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 }; 142 158 return t; 143 159 } // if 144 160 } // ?+? 145 161 146 Rational ?-?( Rational l, Rational r ) { 162 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 163 Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 147 164 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 }; 149 166 return t; 150 167 } 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 }; 152 169 return t; 153 170 } // if 154 171 } // ?-? 155 172 156 Rational ?*?( Rational l, Rational r ) { 157 Rational t = { l.numerator * r.numerator, l.denominator * r.denominator }; 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 }; 158 176 return t; 159 177 } // ?*? 160 178 161 Rational ?/?( Rational l, Rational r ) { 162 if ( r.numerator < 0 ) { 179 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 180 Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 181 if ( r.numerator < (RationalImpl){0} ) { 163 182 r.numerator = -r.numerator; 164 183 r.denominator = -r.denominator; 165 184 } // if 166 Rational t = { l.numerator * r.denominator, l.denominator * r.numerator };185 Rational(RationalImpl) t = { l.numerator * r.denominator, l.denominator * r.numerator }; 167 186 return t; 168 187 } // ?/? … … 171 190 // conversion 172 191 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 204 225 205 226 206 227 // I/O 207 228 208 forall( dtype istype | istream( istype ) ) 209 istype * ?|?( istype *is, Rational *r ) { 229 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 230 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } ) 231 istype * ?|?( istype * is, Rational(RationalImpl) * r ) { 210 232 RationalImpl t; 211 233 is | &(r->numerator) | &(r->denominator); … … 216 238 } // ?|? 217 239 218 forall( dtype ostype | ostream( ostype ) ) 219 ostype * ?|?( ostype *os, Rational r ) { 240 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 241 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } ) 242 ostype * ?|?( ostype * os, Rational(RationalImpl ) r ) { 220 243 return os | r.numerator | '/' | r.denominator; 221 244 } // ?|? -
src/libcfa/stdlib
rce8c12f rd36c117 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Apr 1 17:35:24 201713 // Update Count : 10 412 // Last Modified On : Tue May 9 08:42:44 2017 13 // Update Count : 107 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 86 87 forall( otype T | { int ?<?( T, T ); } ) 87 88 unsigned int bsearch( T key, const T * arr, size_t dimension ); 89 88 90 89 91 forall( otype T | { int ?<?( T, T ); } ) … … 107 109 double abs( double _Complex ); 108 110 long double abs( long double _Complex ); 111 forall ( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } ) 112 T abs( T ); 109 113 110 114 //--------------------------------------- -
src/libcfa/stdlib.c
rce8c12f rd36c117 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Apr 16 10:41:05201713 // Update Count : 1 8912 // Last Modified On : Tue May 9 08:43:00 2017 13 // Update Count : 191 14 14 // 15 15 … … 27 27 } // extern "C" 28 28 29 forall( dtype T | sized(T) ) T * malloc( void ) { 30 //printf( "malloc1\n" ); 31 return (T *)(void*)malloc( (size_t)sizeof(T) ); 29 forall( dtype T | sized(T) ) T * malloc( void ) { // type-safe 30 return (T *)(void *)malloc( (size_t)sizeof(T) ); 32 31 } // 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 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) ); 36 35 return memset( ptr, (int)fill, sizeof(T) ); 37 36 } // malloc 38 37 39 forall( dtype T | sized(T) ) T * calloc( size_t nmemb ) { 40 //printf( "calloc\n" ); 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 41 48 return (T *)calloc( nmemb, sizeof(T) ); 42 49 } // calloc 43 50 44 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) { 45 //printf( "realloc1\n" ); 51 52 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) { // type-safe 46 53 return (T *)(void *)realloc( (void *)ptr, size ); 47 54 } // realloc 48 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) { 49 //printf( "realloc2\n" ); 55 56 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) { // alternative realloc with fill value 50 57 char * nptr = (T *)(void *)realloc( (void *)ptr, size ); 51 58 size_t unused = malloc_usable_size( nptr ); … … 54 61 } // realloc 55 62 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 64 forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ) { // aligned allocation 67 65 return (T *)memalign( alignment, sizeof(T) ); 68 66 } // aligned_alloc 69 67 70 68 forall( dtype T | sized(T) ) T * memalign( size_t alignment ) { 71 //printf( "memalign\n" );72 69 return (T *)memalign( alignment, sizeof(T) ); 73 70 } // memalign 74 71 75 72 forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment ) { 76 //printf( "posix_memalign\n" );77 73 return posix_memalign( (void **)ptr, alignment, sizeof(T) ); 78 74 } // posix_memalign 79 75 80 forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } ) 76 77 forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } ) // new 81 78 T * new( Params p ) { 82 79 return ((T *)malloc()){ p }; 83 } 84 85 forall( dtype T | { void ^?{}(T *); } ) 80 } // new 81 82 forall( dtype T | { void ^?{}(T *); } ) // delete 86 83 void delete( T * ptr ) { 87 88 89 90 91 } 84 if ( ptr ) { 85 ^ptr{}; 86 free( ptr ); 87 } 88 } // delete 92 89 93 90 forall( dtype T, ttype Params | { void ^?{}(T *); void delete(Params); } ) … … 98 95 } 99 96 delete( rest ); 100 } 97 } // delete 101 98 102 99 //--------------------------------------- … … 106 103 if ( sscanf( ptr, "%d", &i ) == EOF ) {} 107 104 return i; 108 } 105 } // ato 106 109 107 unsigned int ato( const char * ptr ) { 110 108 unsigned int ui; 111 109 if ( sscanf( ptr, "%u", &ui ) == EOF ) {} 112 110 return ui; 113 } 111 } // ato 112 114 113 long int ato( const char * ptr ) { 115 114 long int li; 116 115 if ( sscanf( ptr, "%ld", &li ) == EOF ) {} 117 116 return li; 118 } 117 } // ato 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 } 123 } // ato 124 124 125 long long int ato( const char * ptr ) { 125 126 long long int lli; 126 127 if ( sscanf( ptr, "%lld", &lli ) == EOF ) {} 127 128 return lli; 128 } 129 } // ato 130 129 131 unsigned long long int ato( const char * ptr ) { 130 132 unsigned long long int ulli; 131 133 if ( sscanf( ptr, "%llu", &ulli ) == EOF ) {} 132 134 return ulli; 133 } 135 } // ato 136 134 137 135 138 float ato( const char * ptr ) { … … 137 140 if ( sscanf( ptr, "%f", &f ) == EOF ) {} 138 141 return f; 139 } 142 } // ato 143 140 144 double ato( const char * ptr ) { 141 145 double d; 142 146 if ( sscanf( ptr, "%lf", &d ) == EOF ) {} 143 147 return d; 144 } 148 } // ato 149 145 150 long double ato( const char * ptr ) { 146 151 long double ld; 147 152 if ( sscanf( ptr, "%Lf", &ld ) == EOF ) {} 148 153 return ld; 149 } 154 } // ato 155 150 156 151 157 float _Complex ato( const char * ptr ) { … … 153 159 if ( sscanf( ptr, "%g%gi", &re, &im ) == EOF ) {} 154 160 return re + im * _Complex_I; 155 } 161 } // ato 162 156 163 double _Complex ato( const char * ptr ) { 157 164 double re, im; 158 165 if ( sscanf( ptr, "%lf%lfi", &re, &im ) == EOF ) {} 159 166 return re + im * _Complex_I; 160 } 167 } // ato 168 161 169 long double _Complex ato( const char * ptr ) { 162 170 long double re, im; 163 171 if ( sscanf( ptr, "%Lf%Lfi", &re, &im ) == EOF ) {} 164 172 return re + im * _Complex_I; 165 } 173 } // ato 174 166 175 167 176 int strto( const char * sptr, char ** eptr, int base ) { 168 177 return (int)strtol( sptr, eptr, base ); 169 } 178 } // strto 179 170 180 unsigned int strto( const char * sptr, char ** eptr, int base ) { 171 181 return (unsigned int)strtoul( sptr, eptr, base ); 172 } 182 } // strto 183 173 184 long int strto( const char * sptr, char ** eptr, int base ) { 174 185 return strtol( sptr, eptr, base ); 175 } 186 } // strto 187 176 188 unsigned long int strto( const char * sptr, char ** eptr, int base ) { 177 189 return strtoul( sptr, eptr, base ); 178 } 190 } // strto 191 179 192 long long int strto( const char * sptr, char ** eptr, int base ) { 180 193 return strtoll( sptr, eptr, base ); 181 } 194 } // strto 195 182 196 unsigned long long int strto( const char * sptr, char ** eptr, int base ) { 183 197 return strtoull( sptr, eptr, base ); 184 } 198 } // strto 199 185 200 186 201 float strto( const char * sptr, char ** eptr ) { 187 202 return strtof( sptr, eptr ); 188 } 203 } // strto 204 189 205 double strto( const char * sptr, char ** eptr ) { 190 206 return strtod( sptr, eptr ); 191 } 207 } // strto 208 192 209 long double strto( const char * sptr, char ** eptr ) { 193 210 return strtold( sptr, eptr ); 194 } 211 } // strto 212 195 213 196 214 float _Complex strto( const char * sptr, char ** eptr ) { … … 201 219 if ( sptr == *eptr ) return 0.0; 202 220 return re + im * _Complex_I; 203 } 221 } // strto 222 204 223 double _Complex strto( const char * sptr, char ** eptr ) { 205 224 double re, im; … … 209 228 if ( sptr == *eptr ) return 0.0; 210 229 return re + im * _Complex_I; 211 } 230 } // strto 231 212 232 long double _Complex strto( const char * sptr, char ** eptr ) { 213 233 long double re, im; … … 217 237 if ( sptr == *eptr ) return 0.0; 218 238 return re + im * _Complex_I; 219 } 239 } // strto 220 240 221 241 //--------------------------------------- -
src/tests/.expect/concurrent/sched-int-wait.txt
rce8c12f rd36c117 1 Starting 2 Done -
src/tests/.expect/rational.txt
rce8c12f rd36c117 17 17 3/1 18 18 4/3 19 conversion20 0.7521 0.14285714285714322 3.1415929203539823 3/424 1/725 355/11326 19 decompose 27 20 more tests -
src/tests/Makefile.am
rce8c12f rd36c117 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Thu Feb 16 15:27:50201714 ## Update Count : 4 113 ## Last Modified On : Sun May 14 14:43:48 2017 14 ## Update Count : 42 15 15 ############################################################################### 16 16 … … 90 90 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 91 91 92 gmp : gmp.c 93 ${CC} ${CFLAGS} -lgmp ${<} -o ${@} 94 92 95 memberCtors-ERR1: memberCtors.c 93 96 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} -
src/tests/Makefile.in
rce8c12f rd36c117 709 709 ${CC} ${CFLAGS} -CFA -XCFA -p -XCFA -L ${<} -o ${@} 710 710 711 gmp : gmp.c 712 ${CC} ${CFLAGS} -lgmp ${<} -o ${@} 713 711 714 memberCtors-ERR1: memberCtors.c 712 715 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} -
src/tests/rational.c
rce8c12f rd36c117 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 2 22:11:05201713 // Update Count : 4112 // Last Modified On : Sun May 14 18:10:28 2017 13 // Update Count : 57 14 14 // 15 15 16 #include <rational> 16 17 #include <limits> 17 #include < rational>18 #include <stdlib> 18 19 #include <fstream> 20 21 // UNNECESSARY, FIX ME 22 void ?{}( int * this ) { *this = 0; } 23 void ?{}( int * this, zero_t ) { *this = 0; } 24 void ?{}( int * this, one_t ) { *this = 1; } 19 25 20 26 int main() { 21 27 sout | "constructor" | endl; 22 Rational a = { 3 }, b = { 4 }, c;28 Rational(int) a = { 3 }, b = { 4 }, c; 23 29 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 }; 26 33 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 }; 29 36 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 }; 32 39 sout | a | b | endl; 33 40 34 41 sout | "logical" | endl; 35 a = (Rational ){ -2 };36 b = (Rational ){ -3, 2 };42 a = (Rational(int)){ -2 }; 43 b = (Rational(int)){ -3, 2 }; 37 44 sout | a | b | endl; 38 45 // sout | a == 1 | endl; // FIX ME … … 50 57 sout | a / b | endl; 51 58 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; 62 69 63 70 sout | "decompose" | endl; 64 RationalImpln, d;71 int n, d; 65 72 // [n, d] = a; 66 73 // sout | a | n | d | endl; 67 74 68 75 sout | "more tests" | endl; 69 Rational x = { 1, 2 }, y = { 2 };76 Rational(int) x = { 1, 2 }, y = { 2 }; 70 77 sout | x - y | endl; 71 78 sout | x > y | endl; … … 73 80 sout | y | denominator( y, -2 ) | y | endl; 74 81 75 Rational z = { 0, 5 };82 Rational(int) z = { 0, 5 }; 76 83 sout | z | endl; 77 84 78 85 sout | x | numerator( x, 0 ) | x | endl; 79 86 80 x = (Rational ){ 1, MAX } + (Rational){ 1, MAX };87 x = (Rational(int)){ 1, MAX } + (Rational(int)){ 1, MAX }; 81 88 sout | x | endl; 82 x = (Rational ){ 3, MAX } + (Rational){ 2, MAX };89 x = (Rational(int)){ 3, MAX } + (Rational(int)){ 2, MAX }; 83 90 sout | x | endl; 84 91 -
src/tests/sched-int-wait.c
rce8c12f rd36c117 113 113 waiter_left = 4; 114 114 processor p; 115 sout | "Starting" | endl; 115 116 { 116 117 Signaler e; … … 122 123 } 123 124 } 125 sout | "Done" | endl; 124 126 }
Note: See TracChangeset
for help on using the changeset viewer.