Changeset 000ff2c
- Timestamp:
- Mar 2, 2018, 6:22:52 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:
- 2097cd4, 82c367d
- Parents:
- 938dd75 (diff), c9b3a41 (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:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/bibliography/pl.bib
r938dd75 r000ff2c 6687 6687 contributer = {pabuhr@plg}, 6688 6688 author = {{TIOBE Index}}, 6689 year = { March 2017},6689 year = {February 2018}, 6690 6690 url = {http://www.tiobe.com/tiobe_index}, 6691 6691 } -
doc/papers/general/Paper.tex
r938dd75 r000ff2c 199 199 The C programming language is a foundational technology for modern computing with millions of lines of code implementing everything from commercial operating-systems to hobby projects. 200 200 This installation base and the programmers producing it represent a massive software-engineering investment spanning decades and likely to continue for decades more. 201 The TIOBE~\cite{TIOBE} ranks the top 5 most popular programming languages as: Java 16\%, \Textbf{C 7\%}, \Textbf{\CC 5\%}, \Csharp 4\%, Python 4\% = 36\%, where the next 50 languages are less than 3\% each with a long tail.201 The TIOBE~\cite{TIOBE} ranks the top 5 most \emph{popular} programming languages as: Java 15\%, \Textbf{C 12\%}, \Textbf{\CC 5.5\%}, Python 5\%, \Csharp 4.5\% = 42\%, where the next 50 languages are less than 4\% each with a long tail. 202 202 The top 3 rankings over the past 30 years are: 203 203 \begin{center} … … 205 205 \lstDeleteShortInline@% 206 206 \begin{tabular}{@{}rccccccc@{}} 207 & 201 7 & 2012 & 2007 & 2002 & 1997 & 1992 & 1987\\ \hline208 Java & 1 & 1 & 1 & 1 & 12 & - & -\\209 \Textbf{C} & \Textbf{2}& \Textbf{2}& \Textbf{2}& \Textbf{2}& \Textbf{1}& \Textbf{1}& \Textbf{1}\\210 \CC & 3 & 3 & 3 & 3 & 2 & 2 & 4\\207 & 2018 & 2013 & 2008 & 2003 & 1998 & 1993 & 1988 \\ \hline 208 Java & 1 & 2 & 1 & 1 & 18 & - & - \\ 209 \Textbf{C}& \Textbf{2} & \Textbf{1} & \Textbf{2} & \Textbf{2} & \Textbf{1} & \Textbf{1} & \Textbf{1} \\ 210 \CC & 3 & 4 & 3 & 3 & 2 & 2 & 5 \\ 211 211 \end{tabular} 212 212 \lstMakeShortInline@% … … 227 227 \CFA is currently implemented as a source-to-source translator from \CFA to the gcc-dialect of C~\cite{GCCExtensions}, allowing it to leverage the portability and code optimizations provided by gcc, meeting goals (1)--(3). 228 228 Ultimately, a compiler is necessary for advanced features and optimal performance. 229 230 This paper identifies shortcomings in existing approaches to generic and variadic data types in C-like languages and presents a design for generic and variadic types avoiding those shortcomings. 229 All of the features discussed in this paper are working, unless a feature states it is a future feature for completion. 230 231 232 \section{Polymorphic Functions} 233 234 \CFA introduces both ad-hoc and parametric polymorphism to C, with a design originally formalized by Ditchfield~\cite{Ditchfield92}, and first implemented by Bilson~\cite{Bilson03}. 235 Shortcomings are identified in existing approaches to generic and variadic data types in C-like languages and how these shortcomings are avoided in \CFA. 231 236 Specifically, the solution is both reusable and type-checked, as well as conforming to the design goals of \CFA with ergonomic use of existing C abstractions. 232 The new constructs are empirically compared with both standard C and \CC; the results show the new design is comparable in performance. 233 234 \section{Polymorphic Functions} 235 236 \CFA introduces both ad-hoc and parametric polymorphism to C, with a design originally formalized by Ditchfield~\cite{Ditchfield92}, and first implemented by Bilson~\cite{Bilson03}. 237 The new constructs are empirically compared with C and \CC approaches via performance experiments in Section~\ref{sec:eval}. 238 237 239 238 240 \subsection{Name Overloading} 239 241 \label{s:NameOverloading} 242 243 \begin{quote} 244 There are only two hard things in Computer Science: cache invalidation and \emph{naming things} -- Phil Karlton 245 \end{quote} 240 246 C already has a limited form of ad-hoc polymorphism in the form of its basic arithmetic operators, which apply to a variety of different types using identical syntax. 241 247 \CFA extends the built-in operator overloading by allowing users to define overloads for any function, not just operators, and even any variable; … … 245 251 246 252 \begin{cfa} 247 int max(int a, int b) { return a < b ? b : a; } // (1) 248 double max(double a, double b) { return a < b ? b : a; } // (2) 249 250 int max = INT_MAX; // (3) 251 double max = DBL_MAX; // (4) 252 253 max(7, -max); $\C{// uses (1) and (3), by matching int from constant 7}$ 254 max(max, 3.14); $\C{// uses (2) and (4), by matching double from constant 3.14}$ 255 256 //max(max, -max); $\C{// ERROR: ambiguous}$ 257 int m = max(max, -max); $\C{// uses (1) once and (3) twice, by matching return type}$ 258 \end{cfa} 259 260 \Celeven did add @_Generic@ expressions, which can be used in preprocessor macros to provide a form of ad-hoc polymorphism; however, this polymorphism is both functionally and ergonomically inferior to \CFA name overloading. 253 int max = 2147483647; $\C[3.75in]{// (1)}$ 254 double max = 1.7976931348623157E+308; $\C{// (2)}$ 255 int max( int a, int b ) { return a < b ? b : a; } $\C{// (3)}$ 256 double max( double a, double b ) { return a < b ? b : a; } $\C{// (4)}\CRT$ 257 max( 7, -max ); $\C{// uses (3) and (1), by matching int from constant 7}$ 258 max( max, 3.14 ); $\C{// uses (4) and (2), by matching double from constant 3.14}$ 259 max( max, -max ); $\C{// ERROR: ambiguous}$ 260 int m = max( max, -max ); $\C{// uses (3) and (1) twice, by matching return type}$ 261 \end{cfa} 262 \CFA maximizes the ability to reuse names to aggressively address the naming problem. 263 In some cases, hundreds of names can be reduced to tens, resulting in a significant cognitive reduction for a programmer. 264 In the above, the name @max@ has a consistent meaning, and a programmer only needs to remember the single concept: maximum. 265 To prevent significant ambiguities, \CFA uses the return type in selecting overloads, \eg in the assignment to @m@, the compiler use @m@'s type to unambiguously select the most appropriate call to function @max@ (as does Ada). 266 As is shown later, there are a number of situations where \CFA takes advantage of available type information to disambiguate, where other programming languages generate ambiguities. 267 268 \Celeven added @_Generic@ expressions, which can be used in preprocessor macros to provide a form of ad-hoc polymorphism; however, this polymorphism is both functionally and ergonomically inferior to \CFA name overloading. 261 269 The macro wrapping the generic expression imposes some limitations; as an example, it could not implement the example above, because the variables @max@ would collide with the functions @max@. 262 270 Ergonomic limitations of @_Generic@ include the necessity to put a fixed list of supported types in a single place and manually dispatch to appropriate overloads, as well as possible namespace pollution from the functions dispatched to, which must all have distinct names. 263 Though name-overloading removes a major use-case for @_Generic@ expressions, \CFA does implement@_Generic@ for backwards-compatibility purposes. \TODO{actually implement that}271 Though name-overloading removes a major use-case for @_Generic@ expressions, \CFA implements @_Generic@ for backwards-compatibility purposes. \TODO{actually implement that} 264 272 265 273 % http://fanf.livejournal.com/144696.html … … 288 296 For example, the function @twice@ can be defined using the \CFA syntax for operator overloading: 289 297 \begin{cfa} 290 forall( otype T `| { T ?+?(T, T); }` ) T twice( T x ) { return x +x; } $\C{// ? denotes operands}$298 forall( otype T `| { T ?+?(T, T); }` ) T twice( T x ) { return x `+` x; } $\C{// ? denotes operands}$ 291 299 int val = twice( twice( 3.7 ) ); 292 300 \end{cfa} … … 343 351 \begin{cfa} 344 352 forall( otype T | { int ?<?( T, T ); } ) void qsort( const T * arr, size_t size ) { /* use C qsort */ } 345 { int ?<?( double x, double y ) { return x `>` y; } $\C{// locally override behaviour}$ 353 { 354 int ?<?( double x, double y ) { return x `>` y; } $\C{// locally override behaviour}$ 346 355 qsort( vals, size ); $\C{// descending sort}$ 347 356 } … … 414 423 \section{Generic Types} 415 424 416 One of the known shortcomings of standard C is that it does not providereusable type-safe abstractions for generic data structures and algorithms.425 A significant shortcoming of standard C is the lack of reusable type-safe abstractions for generic data structures and algorithms. 417 426 Broadly speaking, there are three approaches to implement abstract data-structures in C. 418 427 One approach is to write bespoke data-structures for each context in which they are needed. 419 428 While this approach is flexible and supports integration with the C type-checker and tooling, it is also tedious and error-prone, especially for more complex data structures. 420 A second approach is to use @void *@--based polymorphism, \eg the C standard-library functions @bsearch@ and @qsort@ ; an approach which does allow reuse of code forcommon functionality.421 However, basing all polymorphism on @void *@ eliminates the type-checker's ability to ensure that argument types are properly matched, often requiring a number of extra function parameters, pointer indirection, and dynamic allocation that would not otherwise be needed.429 A second approach is to use @void *@--based polymorphism, \eg the C standard-library functions @bsearch@ and @qsort@, which allows reuse of code with common functionality. 430 However, basing all polymorphism on @void *@ eliminates the type-checker's ability to ensure that argument types are properly matched, often requiring a number of extra function parameters, pointer indirection, and dynamic allocation that is not otherwise needed. 422 431 A third approach to generic code is to use preprocessor macros, which does allow the generated code to be both generic and type-checked, but errors may be difficult to interpret. 423 432 Furthermore, writing and using preprocessor macros can be unnatural and inflexible. … … 434 443 }; 435 444 forall( otype T ) T value( pair( const char *, T ) p ) { return p.second; } 436 forall( dtype F, otype T ) T value _p( pair( F *, T * ) p ) { return *p.second; }445 forall( dtype F, otype T ) T value( pair( F *, T * ) p ) { return *p.second; } 437 446 438 447 pair( const char *, int ) p = { "magic", 42 }; 439 int magic= value( p );448 int i = value( p ); 440 449 pair( void *, int * ) q = { 0, &p.second }; 441 magic = value_p( q );450 i = value( q ); 442 451 double d = 1.0; 443 452 pair( double *, double * ) r = { &d, &d }; 444 d = value _p( r );453 d = value( r ); 445 454 \end{cfa} 446 455 … … 589 598 [ double ] foo$\(_2\)$( int ); 590 599 void bar( int, double, double ); 591 bar( foo( 3 ), foo( 3 ) );600 `bar`( foo( 3 ), foo( 3 ) ); 592 601 \end{cfa} 593 602 The type-resolver only has the tuple return-types to resolve the call to @bar@ as the @foo@ parameters are identical, which involves unifying the possible @foo@ functions with @bar@'s parameter list. … … 835 844 Since @sum@\(_0\) does not accept any arguments, it is not a valid candidate function for the call @sum(10, 20, 30)@. 836 845 In order to call @sum@\(_1\), @10@ is matched with @x@, and the argument resolution moves on to the argument pack @rest@, which consumes the remainder of the argument list and @Params@ is bound to @[20, 30]@. 837 The process continues un itl @Params@ is bound to @[]@, requiring an assertion @int sum()@, which matches @sum@\(_0\) and terminates the recursion.846 The process continues until @Params@ is bound to @[]@, requiring an assertion @int sum()@, which matches @sum@\(_0\) and terminates the recursion. 838 847 Effectively, this algorithm traces as @sum(10, 20, 30)@ $\rightarrow$ @10 + sum(20, 30)@ $\rightarrow$ @10 + (20 + sum(30))@ $\rightarrow$ @10 + (20 + (30 + sum()))@ $\rightarrow$ @10 + (20 + (30 + 0))@. 839 848 … … 1161 1170 @case@ clauses are made disjoint by the @break@ statement. 1162 1171 While the ability to fall through \emph{is} a useful form of control flow, it does not match well with programmer intuition, resulting in many errors from missing @break@ statements. 1163 For backwards compatibility, \CFA provides a \emph{new} control structure, @choose@, which mimics @switch@, but reverses the meaning of fall through: 1164 \begin{cquote} 1172 For backwards compatibility, \CFA provides a \emph{new} control structure, @choose@, which mimics @switch@, but reverses the meaning of fall through (see Figure~\ref{f:ChooseSwitchStatements}). 1173 Collectively, these enhancements reduce programmer burden and increase readability and safety. 1174 1175 \begin{figure} 1176 \centering 1165 1177 \lstDeleteShortInline@% 1166 \begin{tabular}{@{}l@{\hspace{ \parindentlnth}}l@{}}1167 \multicolumn{1}{c@{\hspace{ \parindentlnth}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\1178 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}} 1179 \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1168 1180 \begin{cfa} 1169 1181 `choose` ( day ) { … … 1199 1211 \end{tabular} 1200 1212 \lstMakeShortInline@% 1201 \end{cquote} 1202 Collectively, these enhancements reduce programmer burden and increase readability and safety. 1213 \caption{\lstinline|choose| versus \lstinline|switch| Statements} 1214 \label{f:ChooseSwitchStatements} 1215 \end{figure} 1203 1216 1204 1217 \begin{comment} … … 1368 1381 \begin{cquote} 1369 1382 \lstDeleteShortInline@% 1370 \begin{tabular}{@{}l@{\hspace{ \parindentlnth}}l@{}}1371 \multicolumn{1}{c@{\hspace{ \parindentlnth}}}{\textbf{Resumption}} & \multicolumn{1}{c}{\textbf{Recovery}} \\1383 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}} 1384 \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{Resumption}} & \multicolumn{1}{c}{\textbf{Termination}} \\ 1372 1385 \begin{cfa} 1373 1386 `exception R { int fix; };` … … 2067 2080 In many cases, the interface is an inline wrapper providing overloading during compilation but zero cost at runtime. 2068 2081 The following sections give a glimpse of the interface reduction to many C libraries. 2069 In many cases, @signed@/@unsigned@ @char@ and @short@ routines are available (but not shown) to ensure expression computations remain in a single type, as conversions can distort results.2082 In many cases, @signed@/@unsigned@ @char@, @short@, and @_Complex@ routines are available (but not shown) to ensure expression computations remain in a single type, as conversions can distort results. 2070 2083 2071 2084 … … 2099 2112 \begin{cfa} 2100 2113 MIN 2114 2101 2115 MAX 2102 M_PI 2103 M_E 2116 2117 PI 2118 E 2104 2119 \end{cfa} 2105 2120 & 2106 2121 \begin{cfa} 2107 2122 SCHAR_MIN, CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, LLONG_MIN, 2123 FLT_MIN, DBL_MIN, LDBL_MIN 2108 2124 SCHAR_MAX, UCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX, LLONG_MAX, 2109 M_PI, M_PIl, M_CPI, M_CPIl, 2110 M_E, M_El, M_CE, M_CEl 2125 FLT_MAX, DBL_MAX, LDBL_MAX 2126 M_PI, M_PIl 2127 M_E, M_El 2111 2128 \end{cfa} 2112 2129 \end{tabular} … … 2158 2175 While \Celeven has type-generic math~\cite[\S~7.25]{C11} in @tgmath.h@ to provide a similar mechanism, these macros are limited, matching a routine name with a single set of floating type(s). 2159 2176 For example, it is impossible to overload @atan@ for both one and two arguments; 2160 instead the names @atan@ and @atan2@ are required .2177 instead the names @atan@ and @atan2@ are required (see Section~\ref{s:NameOverloading}). 2161 2178 The key observation is that only a restricted set of type-generic macros are provided for a limited set of routine names, which do not generalize across the type system, as in \CFA. 2162 2179 … … 2446 2463 \begin{cfa}[xleftmargin=3\parindentlnth,aboveskip=0pt,belowskip=0pt] 2447 2464 int main( int argc, char * argv[] ) { 2448 FILE * out = fopen( "cfa-out.txt", "w" ); 2449 int maxi = 0, vali = 42; 2450 stack(int) si, ti; 2451 2452 REPEAT_TIMED( "push_int", N, push( &si, vali ); ) 2453 TIMED( "copy_int", ti = si; ) 2454 TIMED( "clear_int", clear( &si ); ) 2455 REPEAT_TIMED( "pop_int", N, 2456 int xi = pop( &ti ); if ( xi > maxi ) { maxi = xi; } ) 2457 REPEAT_TIMED( "print_int", N/2, print( out, vali, ":", vali, "\n" ); ) 2458 2459 pair(_Bool, char) maxp = { (_Bool)0, '\0' }, valp = { (_Bool)1, 'a' }; 2460 stack(pair(_Bool, char)) sp, tp; 2461 2462 REPEAT_TIMED( "push_pair", N, push( &sp, valp ); ) 2463 TIMED( "copy_pair", tp = sp; ) 2464 TIMED( "clear_pair", clear( &sp ); ) 2465 REPEAT_TIMED( "pop_pair", N, 2466 pair(_Bool, char) xp = pop( &tp ); if ( xp > maxp ) { maxp = xp; } ) 2467 REPEAT_TIMED( "print_pair", N/2, print( out, valp, ":", valp, "\n" ); ) 2468 fclose(out); 2465 ofstream out = { "cfa-out.txt" }; 2466 int max = 0, val = 42; 2467 stack( int ) si, t; 2468 2469 REPEAT_TIMED( "push_int", N, push( si, val ); ) 2470 TIMED( "copy_int", t = si; ) 2471 TIMED( "clear_int", clear( si ); ) 2472 REPEAT_TIMED( "pop_int", N, int x = pop( t ); max = max( x, max ); ) 2473 REPEAT_TIMED( "print_int", N/2, out | val | ':' | val | endl; ) 2474 2475 pair( _Bool, char ) max = { (_Bool)0, '\0' }, val = { (_Bool)1, 'a' }; 2476 stack( pair( _Bool, char ) ) s, t; 2477 2478 REPEAT_TIMED( "push_pair", N, push( s, val ); ) 2479 TIMED( "copy_pair", t = s; ) 2480 TIMED( "clear_pair", clear( s ); ) 2481 REPEAT_TIMED( "pop_pair", N, pair(_Bool, char) x = pop( t ); max = max( x, max ); ) 2482 REPEAT_TIMED( "print_pair", N/2, out | val | ':' | val | endl; ) 2469 2483 } 2470 2484 \end{cfa} … … 2640 2654 \CFA 2641 2655 \begin{cfa}[xleftmargin=2\parindentlnth,aboveskip=0pt,belowskip=0pt] 2656 forall(otype T) struct stack_node; 2657 forall(otype T) struct stack { 2658 stack_node(T) * head; 2659 }; 2642 2660 forall(otype T) struct stack_node { 2643 2661 T value; 2644 2662 stack_node(T) * next; 2645 2663 }; 2646 forall(otype T) void ?{}( stack(T) * s) { (&s->head){ 0 }; }2647 forall(otype T) void ?{}( stack(T) * s, stack(T) t) {2648 stack_node(T) ** crnt = &s ->head;2664 forall(otype T) void ?{}( stack(T) & s ) { (s.head){ 0 }; } 2665 forall(otype T) void ?{}( stack(T) & s, stack(T) t ) { 2666 stack_node(T) ** crnt = &s.head; 2649 2667 for ( stack_node(T) * next = t.head; next; next = next->next ) { 2650 *crnt = ((stack_node(T) *)malloc()){ next->value }; /***/2668 *crnt = malloc(){ next->value }; 2651 2669 stack_node(T) * acrnt = *crnt; 2652 2670 crnt = &acrnt->next; … … 2654 2672 *crnt = 0; 2655 2673 } 2656 forall(otype T) stack(T) ?=?( stack(T) * s, stack(T) t) {2657 if ( s ->head == t.head ) return *s;2658 clear( s);2674 forall(otype T) stack(T) ?=?( stack(T) & s, stack(T) t ) { 2675 if ( s.head == t.head ) return s; 2676 clear( s ); 2659 2677 s{ t }; 2660 return *s;2661 } 2662 forall(otype T) void ^?{}( stack(T) * s) { clear(s); }2663 forall(otype T) _Bool empty( const stack(T) * s) { return s->head == 0; }2664 forall(otype T) void push( stack(T) * s, T value) {2665 s ->head = ((stack_node(T) *)malloc()){ value, s->head }; /***/2666 } 2667 forall(otype T) T pop( stack(T) * s) {2668 stack_node(T) * n = s ->head;2669 s ->head = n->next;2678 return s; 2679 } 2680 forall(otype T) void ^?{}( stack(T) & s) { clear( s ); } 2681 forall(otype T) _Bool empty( const stack(T) & s ) { return s.head == 0; } 2682 forall(otype T) void push( stack(T) & s, T value ) { 2683 s.head = malloc(){ value, s.head }; 2684 } 2685 forall(otype T) T pop( stack(T) & s ) { 2686 stack_node(T) * n = s.head; 2687 s.head = n->next; 2670 2688 T x = n->value; 2671 2689 ^n{}; 2672 free( n);2690 free( n ); 2673 2691 return x; 2674 2692 } 2675 forall(otype T) void clear( stack(T) * s) {2676 for ( stack_node(T) * next = s ->head; next; ) {2693 forall(otype T) void clear( stack(T) & s ) { 2694 for ( stack_node(T) * next = s.head; next; ) { 2677 2695 stack_node(T) * crnt = next; 2678 2696 next = crnt->next; 2679 delete( crnt);2697 delete( crnt ); 2680 2698 } 2681 s ->head = 0;2699 s.head = 0; 2682 2700 } 2683 2701 \end{cfa} … … 2828 2846 2829 2847 \begin{comment} 2830 2831 2848 \subsubsection{bench.h} 2832 2849 (\texttt{bench.hpp} is similar.) -
doc/papers/general/evaluation/cfa-bench.c
r938dd75 r000ff2c 1 #include <stdio.h> 1 #include <fstream> 2 #include <stdlib> 2 3 #include "bench.h" 3 4 #include "cfa-stack.h" … … 5 6 #include "cfa-print.h" 6 7 7 int main( int argc, char * argv[] ) {8 FILE * out = fopen( "/dev/null", "w" );9 int max i = 0, vali= 42;10 stack( int) si, ti;8 int main( int argc, char * argv[] ) { 9 ofstream out = { "/dev/null" }; 10 int max = 0, val = 42; 11 stack( int ) si, t; 11 12 12 REPEAT_TIMED( "push_int", N, push( si, val i); )13 TIMED( "copy_int", t i= si; )13 REPEAT_TIMED( "push_int", N, push( si, val ); ) 14 TIMED( "copy_int", t = si; ) 14 15 TIMED( "clear_int", clear( si ); ) 15 REPEAT_TIMED( "pop_int", N, 16 int xi = pop( ti ); 17 if ( xi > maxi ) { maxi = xi; } ) 18 REPEAT_TIMED( "print_int", N/2, print( out, vali, ":", vali, "\n" ); ) 16 REPEAT_TIMED( "pop_int", N, int x = pop( t ); max = max( x, max ); ) 17 REPEAT_TIMED( "print_int", N/2, out | val | ':' | val | endl; ) 19 18 20 pair( _Bool, char) maxp = { (_Bool)0, '\0' }, valp= { (_Bool)1, 'a' };21 stack( pair(_Bool, char)) sp, tp;19 pair( _Bool, char ) max = { (_Bool)0, '\0' }, val = { (_Bool)1, 'a' }; 20 stack( pair( _Bool, char ) ) s, t; 22 21 23 REPEAT_TIMED( "push_pair", N, push( sp, valp ); ) 24 TIMED( "copy_pair", tp = sp; ) 25 TIMED( "clear_pair", clear( sp ); ) 26 REPEAT_TIMED( "pop_pair", N, 27 pair(_Bool, char) xp = pop( tp ); 28 if ( xp > maxp ) { maxp = xp; } ) 29 REPEAT_TIMED( "print_pair", N/2, print( out, valp, ":", valp, "\n" ); ) 30 fclose(out); 22 REPEAT_TIMED( "push_pair", N, push( s, val ); ) 23 TIMED( "copy_pair", t = s; ) 24 TIMED( "clear_pair", clear( s ); ) 25 REPEAT_TIMED( "pop_pair", N, pair(_Bool, char) x = pop( t ); max = max( x, max ); ) 26 REPEAT_TIMED( "print_pair", N/2, out | val | ':' | val | endl; ) 31 27 } -
doc/papers/general/evaluation/cfa-pair.c
r938dd75 r000ff2c 1 1 #include "cfa-pair.h" 2 #include "fstream" 2 3 3 forall(otype R, otype S 4 forall(otype R, otype S 4 5 | { int ?==?(R, R); int ?<?(R, R); int ?<?(S, S); }) 5 6 int ?<?(pair(R, S) p, pair(R, S) q) { … … 7 8 } 8 9 9 forall(otype R, otype S 10 forall(otype R, otype S 10 11 | { int ?==?(R, R); int ?<?(R, R); int ?<=?(S, S); }) 11 12 int ?<=?(pair(R, S) p, pair(R, S) q) { … … 23 24 } 24 25 25 forall(otype R, otype S 26 forall(otype R, otype S 26 27 | { int ?==?(R, R); int ?>?(R, R); int ?>?(S, S); }) 27 28 int ?>?(pair(R, S) p, pair(R, S) q) { … … 29 30 } 30 31 31 forall(otype R, otype S 32 forall(otype R, otype S 32 33 | { int ?==?(R, R); int ?>?(R, R); int ?>=?(S, S); }) 33 34 int ?>=?(pair(R, S) p, pair(R, S) q) { 34 35 return p.first > q.first || ( p.first == q.first && p.second >= q.second ); 35 36 } 37 38 forall(otype R, otype S) 39 forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, R ); ostype & ?|?( ostype &, S ); }) 40 ostype & ?|?( ostype & os, pair(R, S) p ) { 41 return os | '[' | p.first | ',' | p.second | ']'; 42 } // ?|? -
doc/papers/general/evaluation/cfa-pair.h
r938dd75 r000ff2c 1 1 #pragma once 2 3 #include "iostream" 2 4 3 5 forall(otype R, otype S) struct pair { … … 27 29 | { int ?==?(R, R); int ?>?(R, R); int ?>=?(S, S); }) 28 30 int ?>=?(pair(R, S) p, pair(R, S) q); 31 32 forall(otype R, otype S) 33 forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, pair(R, S) ); }) 34 ostype & ?|?( ostype & os, pair(R, S) ); -
doc/papers/general/evaluation/cfa-stack.c
r938dd75 r000ff2c 4 4 forall(otype T) struct stack_node { 5 5 T value; 6 stack_node(T) * next;6 stack_node(T) * next; 7 7 }; 8 forall(otype T) void ?{}( stack_node(T) & node, T value, stack_node(T) * next ) { 9 node.value = value; 10 node.next = next; 11 } 8 12 9 forall(otype T) void ?{}( stack(T)& s) { (s.head){ 0 }; }13 forall(otype T) void ?{}( stack(T) & s ) { (s.head){ 0 }; } 10 14 11 forall(otype T) void ?{}( stack(T)& s, stack(T) t) {12 stack_node(T) ** crnt = &s.head;13 for ( stack_node(T) * next = t.head; next; next = next->next ) {14 // *crnt = &(*(stack_node(T)*)malloc()){ next->value }; /***/15 forall(otype T) void ?{}( stack(T) & s, stack(T) t ) { 16 stack_node(T) ** crnt = &s.head; 17 for ( stack_node(T) * next = t.head; next; next = next->next ) { 18 // *crnt = new( next->value, 0 ); 15 19 stack_node(T)* new_node = ((stack_node(T)*)malloc()); 16 20 (*new_node){ next->value }; /***/ 17 21 *crnt = new_node; 18 19 stack_node(T)* acrnt = *crnt; 22 stack_node(T) * acrnt = *crnt; 20 23 crnt = &acrnt->next; 21 24 } … … 23 26 } 24 27 25 forall(otype T) stack(T) ?=?( stack(T)& s, stack(T) t) {28 forall(otype T) stack(T) ?=?( stack(T) & s, stack(T) t ) { 26 29 if ( s.head == t.head ) return s; 27 clear( s);30 clear( s ); 28 31 s{ t }; 29 32 return s; 30 33 } 31 34 32 forall(otype T) void ^?{}( stack(T)& s) { clear(s); }35 forall(otype T) void ^?{}( stack(T) & s) { clear( s ); } 33 36 34 forall(otype T) _Bool empty( const stack(T)& s) { return s.head == 0; }37 forall(otype T) _Bool empty( const stack(T) & s ) { return s.head == 0; } 35 38 36 forall(otype T) void push( stack(T)& s, T value) {37 // s.head = &(*(stack_node(T)*)malloc()){ value, s.head }; /***/39 forall(otype T) void push( stack(T) & s, T value ) { 40 // s.head = new( value, s.head ); 38 41 stack_node(T)* new_node = ((stack_node(T)*)malloc()); 39 42 (*new_node){ value, s.head }; /***/ … … 41 44 } 42 45 43 forall(otype T) T pop( stack(T)& s) {44 stack_node(T) * n = s.head;46 forall(otype T) T pop( stack(T) & s ) { 47 stack_node(T) * n = s.head; 45 48 s.head = n->next; 46 T x = n->value; 47 ^n{}; 48 free(n); 49 return x; 49 T v = n->value; 50 delete( n ); 51 return v; 50 52 } 51 53 52 forall(otype T) void clear( stack(T)& s) {53 for ( stack_node(T)* next = s.head; next; ) {54 stack_node(T) * crnt = next;54 forall(otype T) void clear( stack(T) & s ) { 55 for ( stack_node(T) * next = s.head; next; ) { 56 stack_node(T) * crnt = next; 55 57 next = crnt->next; 56 delete( crnt);58 delete( crnt ); 57 59 } 58 60 s.head = 0; -
doc/papers/general/evaluation/cfa-stack.h
r938dd75 r000ff2c 3 3 forall(otype T) struct stack_node; 4 4 forall(otype T) struct stack { 5 stack_node(T) * head;5 stack_node(T) * head; 6 6 }; 7 7 8 forall(otype T) void ?{}( stack(T)& s);9 forall(otype T) void ?{}( stack(T)& s, stack(T) t);10 forall(otype T) stack(T) ?=?( stack(T)& s, stack(T) t);11 forall(otype T) void ^?{}( stack(T)& s);8 forall(otype T) void ?{}( stack(T) & s ); 9 forall(otype T) void ?{}( stack(T) & s, stack(T) t ); 10 forall(otype T) stack(T) ?=?( stack(T) & s, stack(T) t ); 11 forall(otype T) void ^?{}( stack(T) & s); 12 12 13 forall(otype T) _Bool empty( const stack(T)& s);14 forall(otype T) void push( stack(T)& s, T value);15 forall(otype T) T pop( stack(T)& s);16 forall(otype T) void clear( stack(T)& s);13 forall(otype T) _Bool empty( const stack(T) & s ); 14 forall(otype T) void push( stack(T) & s, T value ); 15 forall(otype T) T pop( stack(T) & s ); 16 forall(otype T) void clear( stack(T) & s ); -
src/libcfa/limits
r938dd75 r000ff2c 10 10 // Created On : Wed Apr 6 18:06:52 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 7 09:33:57 201713 // Update Count : 712 // Last Modified On : Thu Mar 1 16:20:54 2018 13 // Update Count : 13 14 14 // 15 15 … … 18 18 // Integral Constants 19 19 20 extern const signed char MIN; 21 extern const unsigned char MIN; 20 22 extern const short int MIN; 23 extern const unsigned short int MIN; 21 24 extern const int MIN; 25 extern const unsigned int MIN; 22 26 extern const long int MIN; 27 extern const unsigned long int MIN; 23 28 extern const long long int MIN; 29 extern const unsigned long long int MIN; 24 30 31 extern const signed char MAX; 32 extern const unsigned char MAX; 25 33 extern const short int MAX; 26 34 extern const unsigned short int MAX; … … 33 41 34 42 // Floating-Point Constants 43 44 extern const float MIN; 45 extern const double MIN; 46 extern const long double MIN; 47 extern const float _Complex MIN; 48 extern const double _Complex MIN; 49 extern const long double _Complex MIN; 50 51 extern const float MAX; 52 extern const double MAX; 53 extern const long double MAX; 54 extern const float _Complex MAX; 55 extern const double _Complex MAX; 56 extern const long double _Complex MAX; 35 57 36 58 extern const float PI; // pi … … 55 77 extern const long double _2_SQRT_PI; // 2 / sqrt(pi) 56 78 57 extern const _Complex PI;// pi58 extern const _Complex PI_2;// pi / 259 extern const _Complex PI_4;// pi / 460 extern const _Complex _1_PI;// 1 / pi61 extern const _Complex _2_PI;// 2 / pi62 extern const _Complex _2_SQRT_PI;// 2 / sqrt(pi)79 extern const float _Complex PI; // pi 80 extern const float _Complex PI_2; // pi / 2 81 extern const float _Complex PI_4; // pi / 4 82 extern const float _Complex _1_PI; // 1 / pi 83 extern const float _Complex _2_PI; // 2 / pi 84 extern const float _Complex _2_SQRT_PI; // 2 / sqrt(pi) 63 85 64 extern const long _Complex PI; // pi 65 extern const long _Complex PI_2; // pi / 2 66 extern const long _Complex PI_4; // pi / 4 67 extern const long _Complex _1_PI; // 1 / pi 68 extern const long _Complex _2_PI; // 2 / pi 69 extern const long _Complex _2_SQRT_PI; // 2 / sqrt(pi) 86 extern const double _Complex PI; // pi 87 extern const double _Complex PI_2; // pi / 2 88 extern const double _Complex PI_4; // pi / 4 89 extern const double _Complex _1_PI; // 1 / pi 90 extern const double _Complex _2_PI; // 2 / pi 91 extern const double _Complex _2_SQRT_PI; // 2 / sqrt(pi) 92 93 extern const long double _Complex PI; // pi 94 extern const long double _Complex PI_2; // pi / 2 95 extern const long double _Complex PI_4; // pi / 4 96 extern const long double _Complex _1_PI; // 1 / pi 97 extern const long double _Complex _2_PI; // 2 / pi 98 extern const long double _Complex _2_SQRT_PI; // 2 / sqrt(pi) 70 99 71 100 extern const float E; // e … … 93 122 extern const long double _1_SQRT_2; // 1/sqrt(2) 94 123 95 extern const _Complex E;// e96 extern const _Complex LOG2_E;// log_2(e)97 extern const _Complex LOG10_E;// log_10(e)98 extern const _Complex LN_2;// log_e(2)99 extern const _Complex LN_10;// log_e(10)100 extern const _Complex SQRT_2;// sqrt(2)101 extern const _Complex _1_SQRT_2;// 1 / sqrt(2)124 extern const float _Complex E; // e 125 extern const float _Complex LOG2_E; // log_2(e) 126 extern const float _Complex LOG10_E; // log_10(e) 127 extern const float _Complex LN_2; // log_e(2) 128 extern const float _Complex LN_10; // log_e(10) 129 extern const float _Complex SQRT_2; // sqrt(2) 130 extern const float _Complex _1_SQRT_2; // 1 / sqrt(2) 102 131 103 extern const long _Complex E; // e 104 extern const long _Complex LOG2_E; // log_2(e) 105 extern const long _Complex LOG10_E; // log_10(e) 106 extern const long _Complex LN_2; // log_e(2) 107 extern const long _Complex LN_10; // log_e(10) 108 extern const long _Complex SQRT_2; // sqrt(2) 109 extern const long _Complex _1_SQRT_2; // 1 / sqrt(2) 132 extern const double _Complex E; // e 133 extern const double _Complex LOG2_E; // log_2(e) 134 extern const double _Complex LOG10_E; // log_10(e) 135 extern const double _Complex LN_2; // log_e(2) 136 extern const double _Complex LN_10; // log_e(10) 137 extern const double _Complex SQRT_2; // sqrt(2) 138 extern const double _Complex _1_SQRT_2; // 1 / sqrt(2) 139 140 extern const long double _Complex E; // e 141 extern const long double _Complex LOG2_E; // log_2(e) 142 extern const long double _Complex LOG10_E; // log_10(e) 143 extern const long double _Complex LN_2; // log_e(2) 144 extern const long double _Complex LN_10; // log_e(10) 145 extern const long double _Complex SQRT_2; // sqrt(2) 146 extern const long double _Complex _1_SQRT_2; // 1 / sqrt(2) 110 147 111 148 // Local Variables: // -
src/libcfa/limits.c
r938dd75 r000ff2c 10 10 // Created On : Wed Apr 6 18:06:52 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 12 10:34:48 201613 // Update Count : 1712 // Last Modified On : Thu Mar 1 16:22:51 2018 13 // Update Count : 74 14 14 // 15 15 16 #include <limits.h> 17 #include <float.h> 18 #define __USE_GNU // get M_* constants 19 #include <math.h> 20 #include <complex.h> 16 21 #include "limits" 17 22 18 23 // Integral Constants 19 24 20 const short int MIN = -32768; 21 const int MIN = -2147483648; 22 #if __WORDSIZE == 64 23 const long int MIN = -9223372036854775807L - 1L; 24 #else 25 const long int MIN = (int)MIN; 26 #endif // M64 27 const long long int MIN = -9223372036854775807LL - 1LL; 25 const signed char MIN = SCHAR_MIN; 26 const unsigned char MIN = 0; 27 const short int MIN = SHRT_MIN; 28 const unsigned short int MIN = 0; 29 const int MIN = INT_MIN; 30 const unsigned int MIN = 0; 31 const long int MIN = LONG_MIN; 32 const unsigned long int MIN = 0; 33 const long long int MIN = LLONG_MIN; 34 const unsigned long long int MIN = 0; 28 35 29 const short int MAX = 32767; 30 const unsigned short int MAX = 65535; 31 const int MAX = 2147483647; 32 const unsigned int MAX = 4294967295_U; 33 #if __WORDSIZE == 64 34 const long int MAX = 9223372036854775807_L; 35 #else 36 const long int MAX = (int)MAX; 37 #endif // M64 38 const unsigned long int MAX = 4294967295_U; 39 const long long int MAX = 9223372036854775807_LL; 40 const unsigned long long int MAX = 18446744073709551615_ULL; 36 const signed char MAX = SCHAR_MAX; 37 const unsigned char MAX = UCHAR_MAX; 38 const short int MAX = SHRT_MAX; 39 const unsigned short int MAX = USHRT_MAX; 40 const int MAX = INT_MAX; 41 const unsigned int MAX = UINT_MAX; 42 const long int MAX = LONG_MAX; 43 const unsigned long int MAX = ULONG_MAX; 44 const long long int MAX = LLONG_MAX; 45 const unsigned long long int MAX = ULLONG_MAX; 41 46 42 47 // Floating-Point Constants 43 48 44 const float PI = 3.141592_F; // pi45 const float PI_2 = 1.570796_F; // pi / 246 const float PI_4 = 0.7853981_F; // pi / 447 const float _ 1_PI = 0.3183098_F; // 1 / pi48 const float _2_PI = 0.6366197_F; // 2 / pi49 const float _2_SQRT_PI = 1.128379_F; // 2 / sqrt(pi)49 const float MIN = FLT_MIN; 50 const double MIN = DBL_MIN; 51 const long double MIN = LDBL_MIN; 52 const float _Complex MIN = __FLT_MIN__ + __FLT_MIN__ * I; 53 const double _Complex MIN = DBL_MIN + DBL_MIN * I; 54 const long double _Complex MIN = LDBL_MIN + LDBL_MIN * I; 50 55 51 const double PI = 3.14159265358979323846_D; // pi52 const double PI_2 = 1.57079632679489661923_D; // pi / 253 const double PI_4 = 0.78539816339744830962_D; // pi / 454 const double _1_PI = 0.31830988618379067154_D; // 1 / pi55 const double _ 2_PI = 0.63661977236758134308_D; // 2 / pi56 const double _2_SQRT_PI = 1.12837916709551257390_D; // 2 / sqrt(pi)56 const float MAX = FLT_MAX; 57 const double MAX = DBL_MAX; 58 const long double MAX = LDBL_MAX; 59 const float _Complex MAX = FLT_MAX + FLT_MAX * I; 60 const double _Complex MAX = DBL_MAX + DBL_MAX * I; 61 const long double _Complex MAX = LDBL_MAX + LDBL_MAX * I; 57 62 58 const long double PI = 3.1415926535897932384626433832795029_DL;// pi59 const long double PI_2 = 1.5707963267948966192313216916397514_DL;// pi / 260 const long double PI_4 = 0.7853981633974483096156608458198757_DL;// pi / 461 const long double _1_PI = 0.3183098861837906715377675267450287_DL;// 1 / pi62 const long double _2_PI = 0.6366197723675813430755350534900574_DL;// 2 / pi63 const long double _2_SQRT_PI = 1.1283791670955125738961589031215452_DL;// 2 / sqrt(pi)63 const float PI = (float)M_PI; // pi 64 const float PI_2 = (float)M_PI_2; // pi / 2 65 const float PI_4 = (float)M_PI_4; // pi / 4 66 const float _1_PI = (float)M_1_PI; // 1 / pi 67 const float _2_PI = (float)M_2_PI; // 2 / pi 68 const float _2_SQRT_PI = (float)M_2_SQRTPI; // 2 / sqrt(pi) 64 69 65 const double _Complex PI = 3.14159265358979323846_D+0.0_iD;// pi66 const double _Complex PI_2 = 1.57079632679489661923_D+0.0_iD;// pi / 267 const double _Complex PI_4 = 0.78539816339744830962_D+0.0_iD;// pi / 468 const double _ Complex _1_PI = 0.31830988618379067154_D+0.0_iD;// 1 / pi69 const double _ Complex _2_PI = 0.63661977236758134308_D+0.0_iD;// 2 / pi70 const double _ Complex _2_SQRT_PI = 1.12837916709551257390_D+0.0_iD;// 2 / sqrt(pi)70 const double PI = M_PI; // pi 71 const double PI_2 = M_PI_2; // pi / 2 72 const double PI_4 = M_PI_4; // pi / 4 73 const double _1_PI = M_1_PI; // 1 / pi 74 const double _2_PI = M_2_PI; // 2 / pi 75 const double _2_SQRT_PI = M_2_SQRTPI; // 2 / sqrt(pi) 71 76 72 const long double _Complex PI = 3.1415926535897932384626433832795029_L+0.0iL;// pi73 const long double _Complex PI_2 = 1.5707963267948966192313216916397514_L+0.0iL;// pi / 274 const long double _Complex PI_4 = 0.7853981633974483096156608458198757_L+0.0iL;// pi / 475 const long double _ Complex _1_PI = 0.3183098861837906715377675267450287_L+0.0iL;// 1 / pi76 const long double _ Complex _2_PI = 0.6366197723675813430755350534900574_L+0.0iL;// 2 / pi77 const long double _ Complex _2_SQRT_PI = 1.1283791670955125738961589031215452_L+0.0iL;// 2 / sqrt(pi)77 const long double PI = M_PIl; // pi 78 const long double PI_2 = M_PI_2l; // pi / 2 79 const long double PI_4 = M_PI_4l; // pi / 4 80 const long double _1_PI = M_1_PIl; // 1 / pi 81 const long double _2_PI = M_2_PIl; // 2 / pi 82 const long double _2_SQRT_PI = M_2_SQRTPIl; // 2 / sqrt(pi) 78 83 79 const float E = 2.718281; // e 80 const float LOG2_E = 1.442695; // log_2(e) 81 const float LOG10_E = 0.4342944; // log_10(e) 82 const float LN_2 = 0.6931471; // log_e(2) 83 const float LN_10 = 2.302585; // log_e(10) 84 const float SQRT_2 = 1.414213; // sqrt(2) 85 const float _1_SQRT_2 = 0.7071067; // 1 / sqrt(2) 84 const float _Complex PI = (float)M_PI + 0.0_iF; // pi 85 const float _Complex PI_2 = (float)M_PI_2 + 0.0_iF; // pi / 2 86 const float _Complex PI_4 = (float)M_PI_4 + 0.0_iF; // pi / 4 87 const float _Complex _1_PI = (float)M_1_PI + 0.0_iF; // 1 / pi 88 const float _Complex _2_PI = (float)M_2_PI + 0.0_iF; // 2 / pi 89 const float _Complex _2_SQRT_PI = (float)M_2_SQRTPI + 0.0_iF; // 2 / sqrt(pi) 86 90 87 const double E = 2.7182818284590452354_D; // e 88 const double LOG2_E = 1.4426950408889634074_D; // log_2(e) 89 const double LOG10_E = 0.43429448190325182765_D; // log_10(e) 90 const double LN_2 = 0.69314718055994530942_D; // log_e(2) 91 const double LN_10 = 2.30258509299404568402_D; // log_e(10) 92 const double SQRT_2 = 1.41421356237309504880_D; // sqrt(2) 93 const double _1_SQRT_2 = 0.70710678118654752440_D; // 1 / sqrt(2) 91 const double _Complex PI = M_PI + 0.0_iD; // pi 92 const double _Complex PI_2 = M_PI_2 + 0.0_iD; // pi / 2 93 const double _Complex PI_4 = M_PI_4 + 0.0_iD; // pi / 4 94 const double _Complex _1_PI = M_1_PI + 0.0_iD; // 1 / pi 95 const double _Complex _2_PI = M_2_PI + 0.0_iD; // 2 / pi 96 const double _Complex _2_SQRT_PI = M_2_SQRTPI + 0.0_iD; // 2 / sqrt(pi) 94 97 95 const long double E = 2.7182818284590452353602874713526625_DL; // e 96 const long double LOG2_E = 1.4426950408889634073599246810018921_DL; // log_2(e) 97 const long double LOG10_E = 0.4342944819032518276511289189166051_DL; // log_10(e) 98 const long double LN_2 = 0.6931471805599453094172321214581766_DL; // log_e(2) 99 const long double LN_10 = 2.3025850929940456840179914546843642_DL; // log_e(10) 100 const long double SQRT_2 = 1.4142135623730950488016887242096981_DL; // sqrt(2) 101 const long double _1_SQRT_2 = 0.7071067811865475244008443621048490_DL; // 1/sqrt(2) 98 const long double _Complex PI = M_PIl + 0.0_iL; // pi 99 const long double _Complex PI_2 = M_PI_2l + 0.0_iL; // pi / 2 100 const long double _Complex PI_4 = M_PI_4l + 0.0_iL; // pi / 4 101 const long double _Complex _1_PI = M_1_PIl + 0.0_iL; // 1 / pi 102 const long double _Complex _2_PI = M_2_PIl + 0.0_iL; // 2 / pi 103 const long double _Complex _2_SQRT_PI = M_2_SQRTPIl + 0.0_iL; // 2 / sqrt(pi) 102 104 103 const double _Complex E = 2.7182818284590452354_D+0.0_iD;// e104 const double _Complex LOG2_E = 1.4426950408889634074_D+0.0_iD;// log_2(e)105 const double _Complex LOG10_E = 0.43429448190325182765_D+0.0_iD;// log_10(e)106 const double _Complex LN_2 = 0.69314718055994530942_D+0.0_iD;// log_e(2)107 const double _Complex LN_10 = 2.30258509299404568402_D+0.0_iD;// log_e(10)108 const double _Complex SQRT_2 = 1.41421356237309504880_D+0.0_iD;// sqrt(2)109 const double _Complex _1_SQRT_2 = 0.70710678118654752440_D+0.0_iD;// 1 / sqrt(2)105 const float E = (float)M_E; // e 106 const float LOG2_E = (float)M_LOG2E; // log_2(e) 107 const float LOG10_E = (float)M_LOG10E; // log_10(e) 108 const float LN_2 = (float)M_LN2; // log_e(2) 109 const float LN_10 = (float)M_LN10; // log_e(10) 110 const float SQRT_2 = (float)M_SQRT2; // sqrt(2) 111 const float _1_SQRT_2 = (float)M_SQRT1_2; // 1 / sqrt(2) 110 112 111 const long double _Complex E = 2.7182818284590452353602874713526625_L+0.0_iL; // e 112 const long double _Complex LOG2_E = 1.4426950408889634073599246810018921_L+0.0_iL; // log_2(e) 113 const long double _Complex LOG10_E = 0.4342944819032518276511289189166051_L+0.0_iL; // log_10(e) 114 const long double _Complex LN_2 = 0.6931471805599453094172321214581766_L+0.0_iL; // log_e(2) 115 const long double _Complex LN_10 = 2.3025850929940456840179914546843642_L+0.0_iL; // log_e(10) 116 const long double _Complex SQRT_2 = 1.4142135623730950488016887242096981_L+0.0_iL; // sqrt(2) 117 const long double _Complex _1_SQRT_2 = 0.7071067811865475244008443621048490_L+0.0_iL; // 1 / sqrt(2) 113 const double E = M_E; // e 114 const double LOG2_E = M_LOG2E; // log_2(e) 115 const double LOG10_E = M_LOG10E; // log_10(e) 116 const double LN_2 = M_LN2; // log_e(2) 117 const double LN_10 = M_LN10; // log_e(10) 118 const double SQRT_2 = M_SQRT2; // sqrt(2) 119 const double _1_SQRT_2 = M_SQRT1_2; // 1 / sqrt(2) 120 121 const long double E = M_El; // e 122 const long double LOG2_E = M_LOG2El; // log_2(e) 123 const long double LOG10_E = M_LOG10El; // log_10(e) 124 const long double LN_2 = M_LN2l; // log_e(2) 125 const long double LN_10 = M_LN10l; // log_e(10) 126 const long double SQRT_2 = M_SQRT2l; // sqrt(2) 127 const long double _1_SQRT_2 = M_SQRT1_2l; // 1 / sqrt(2) 128 129 const float _Complex E = M_E + 0.0_iF; // e 130 const float _Complex LOG2_E = M_LOG2E + 0.0_iF; // log_2(e) 131 const float _Complex LOG10_E = M_LOG10E + 0.0_iF; // log_10(e) 132 const float _Complex LN_2 = M_LN2 + 0.0_iF; // log_e(2) 133 const float _Complex LN_10 = M_LN10 + 0.0_iF; // log_e(10) 134 const float _Complex SQRT_2 = M_SQRT2 + 0.0_iF; // sqrt(2) 135 const float _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iF; // 1 / sqrt(2) 136 137 const double _Complex E = M_E + 0.0_iD; // e 138 const double _Complex LOG2_E = M_LOG2E + 0.0_iD; // log_2(e) 139 const double _Complex LOG10_E = M_LOG10E + 0.0_iD; // log_10(e) 140 const double _Complex LN_2 = M_LN2 + 0.0_iD; // log_e(2) 141 const double _Complex LN_10 = M_LN10 + 0.0_iD; // log_e(10) 142 const double _Complex SQRT_2 = M_SQRT2 + 0.0_iD; // sqrt(2) 143 const double _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iD; // 1 / sqrt(2) 144 145 const long double _Complex E = M_El + 0.0_iL; // e 146 const long double _Complex LOG2_E = M_LOG2El + 0.0_iL; // log_2(e) 147 const long double _Complex LOG10_E = M_LOG10El + 0.0_iL; // log_10(e) 148 const long double _Complex LN_2 = M_LN2l + 0.0_iL; // log_e(2) 149 const long double _Complex LN_10 = M_LN10l + 0.0_iL; // log_e(10) 150 const long double _Complex SQRT_2 = M_SQRT2l + 0.0_iL; // sqrt(2) 151 const long double _Complex _1_SQRT_2 = M_SQRT1_2l + 0.0_iL; // 1 / sqrt(2) 118 152 119 153 // Local Variables: // -
src/tests/limits.c
r938dd75 r000ff2c 10 10 // Created On : Tue May 10 20:44:20 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue May 10 20:45:28 201613 // Update Count : 112 // Last Modified On : Thu Mar 1 16:21:55 2018 13 // Update Count : 7 14 14 // 15 15 … … 18 18 // Integral Constants 19 19 20 signed char m = MIN; 21 unsigned char m = MIN; 20 22 short int m = MIN; 23 unsigned short int m = MIN; 21 24 int m = MIN; 25 unsigned int m = MIN; 22 26 long int m = MIN; 27 unsigned long int m = MIN; 23 28 long long int m = MIN; 29 unsigned long long int m = MIN; 24 30 31 signed char M = MAX; 32 unsigned char M = MAX; 25 33 short int M = MAX; 26 34 unsigned short int M = MAX; … … 33 41 34 42 // Floating-Point Constants 43 44 float m = MIN; 45 double m = MIN; 46 long double m = MIN; 47 float _Complex m = MIN; 48 double _Complex m = MIN; 49 long double _Complex m = MIN; 50 51 float M = MAX; 52 double M = MAX; 53 long double M = MAX; 54 float _Complex M = MAX; 55 double _Complex M = MAX; 56 long double _Complex M = MAX; 35 57 36 58 float pi = PI; … … 55 77 long double _2_sqrt_pi = _2_SQRT_PI; 56 78 57 _Complex pi = PI;58 _Complex pi_2 = PI_2;59 _Complex pi_4 = PI_4;60 _Complex _1_pi = _1_PI;61 _Complex _2_pi = _2_PI;62 _Complex _2_sqrt_pi = _2_SQRT_PI;79 float _Complex pi = PI; 80 float _Complex pi_2 = PI_2; 81 float _Complex pi_4 = PI_4; 82 float _Complex _1_pi = _1_PI; 83 float _Complex _2_pi = _2_PI; 84 float _Complex _2_sqrt_pi = _2_SQRT_PI; 63 85 64 long _Complex pi = PI; 65 long _Complex pi_2 = PI_2; 66 long _Complex pi_4 = PI_4; 67 long _Complex _1_pi = _1_PI; 68 long _Complex _2_pi = _2_PI; 69 long _Complex _2_sqrt_pi = _2_SQRT_PI; 86 double _Complex pi = PI; 87 double _Complex pi_2 = PI_2; 88 double _Complex pi_4 = PI_4; 89 double _Complex _1_pi = _1_PI; 90 double _Complex _2_pi = _2_PI; 91 double _Complex _2_sqrt_pi = _2_SQRT_PI; 92 93 long double _Complex pi = PI; 94 long double _Complex pi_2 = PI_2; 95 long double _Complex pi_4 = PI_4; 96 long double _Complex _1_pi = _1_PI; 97 long double _Complex _2_pi = _2_PI; 98 long double _Complex _2_sqrt_pi = _2_SQRT_PI; 70 99 71 100 float e = E; … … 93 122 long double _1_sqrt_2 = _1_SQRT_2; 94 123 95 _Complex e = E;96 _Complex log2_e = LOG2_E;97 _Complex log10_e = LOG10_E;98 _Complex ln_2 = LN_2;99 _Complex ln_10 = LN_10;100 _Complex sqrt_2 = SQRT_2;101 _Complex _1_sqrt_2 = _1_SQRT_2;124 float _Complex e = E; 125 float _Complex log2_e = LOG2_E; 126 float _Complex log10_e = LOG10_E; 127 float _Complex ln_2 = LN_2; 128 float _Complex ln_10 = LN_10; 129 float _Complex sqrt_2 = SQRT_2; 130 float _Complex _1_sqrt_2 = _1_SQRT_2; 102 131 103 long _Complex e = E; 104 long _Complex log2_e = LOG2_E; 105 long _Complex log10_e = LOG10_E; 106 long _Complex ln_2 = LN_2; 107 long _Complex ln_10 = LN_10; 108 long _Complex sqrt_2 = SQRT_2; 109 long _Complex _1_sqrt_2 = _1_SQRT_2; 132 double _Complex e = E; 133 double _Complex log2_e = LOG2_E; 134 double _Complex log10_e = LOG10_E; 135 double _Complex ln_2 = LN_2; 136 double _Complex ln_10 = LN_10; 137 double _Complex sqrt_2 = SQRT_2; 138 double _Complex _1_sqrt_2 = _1_SQRT_2; 139 140 long double _Complex e = E; 141 long double _Complex log2_e = LOG2_E; 142 long double _Complex log10_e = LOG10_E; 143 long double _Complex ln_2 = LN_2; 144 long double _Complex ln_10 = LN_10; 145 long double _Complex sqrt_2 = SQRT_2; 146 long double _Complex _1_sqrt_2 = _1_SQRT_2; 110 147 111 148 int main(int argc, char const *argv[]) {
Note: See TracChangeset
for help on using the changeset viewer.