Changeset 000ff2c


Ignore:
Timestamp:
Mar 2, 2018, 6:22:52 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • doc/bibliography/pl.bib

    r938dd75 r000ff2c  
    66876687    contributer = {pabuhr@plg},
    66886688    author      = {{TIOBE Index}},
    6689     year        = {March 2017},
     6689    year        = {February 2018},
    66906690    url         = {http://www.tiobe.com/tiobe_index},
    66916691}
  • doc/papers/general/Paper.tex

    r938dd75 r000ff2c  
    199199The 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.
    200200This 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.
     201The 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.
    202202The top 3 rankings over the past 30 years are:
    203203\begin{center}
     
    205205\lstDeleteShortInline@%
    206206\begin{tabular}{@{}rccccccc@{}}
    207                 & 2017  & 2012  & 2007  & 2002  & 1997  & 1992  & 1987          \\ \hline
    208 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
     208Java    & 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             \\
    211211\end{tabular}
    212212\lstMakeShortInline@%
     
    227227\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).
    228228Ultimately, 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.
     229All 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}.
     235Shortcomings are identified in existing approaches to generic and variadic data types in C-like languages and how these shortcomings are avoided in \CFA.
    231236Specifically, 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}.
     237The new constructs are empirically compared with C and \CC approaches via performance experiments in Section~\ref{sec:eval}.
     238
    237239
    238240\subsection{Name Overloading}
    239 
     241\label{s:NameOverloading}
     242
     243\begin{quote}
     244There are only two hard things in Computer Science: cache invalidation and \emph{naming things} -- Phil Karlton
     245\end{quote}
    240246C 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.
    241247\CFA extends the built-in operator overloading by allowing users to define overloads for any function, not just operators, and even any variable;
     
    245251
    246252\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.
     253int max = 2147483647;                                           $\C[3.75in]{// (1)}$
     254double max = 1.7976931348623157E+308;   $\C{// (2)}$
     255int max( int a, int b ) { return a < b ? b : a; }  $\C{// (3)}$
     256double max( double a, double b ) { return a < b ? b : a; }  $\C{// (4)}\CRT$
     257max( 7, -max );                                                         $\C{// uses (3) and (1), by matching int from constant 7}$
     258max( max, 3.14 );                                                       $\C{// uses (4) and (2), by matching double from constant 3.14}$
     259max( max, -max );                                                       $\C{// ERROR: ambiguous}$
     260int 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.
     263In some cases, hundreds of names can be reduced to tens, resulting in a significant cognitive reduction for a programmer.
     264In the above, the name @max@ has a consistent meaning, and a programmer only needs to remember the single concept: maximum.
     265To 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).
     266As 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.
    261269The 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@.
    262270Ergonomic 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}
     271Though name-overloading removes a major use-case for @_Generic@ expressions, \CFA implements @_Generic@ for backwards-compatibility purposes. \TODO{actually implement that}
    264272
    265273% http://fanf.livejournal.com/144696.html
     
    288296For example, the function @twice@ can be defined using the \CFA syntax for operator overloading:
    289297\begin{cfa}
    290 forall( otype T `| { T ?+?(T, T); }` ) T twice( T x ) { return x + x; } $\C{// ? denotes operands}$
     298forall( otype T `| { T ?+?(T, T); }` ) T twice( T x ) { return x `+` x; }       $\C{// ? denotes operands}$
    291299int val = twice( twice( 3.7 ) );
    292300\end{cfa}
     
    343351\begin{cfa}
    344352forall( 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}$
    346355        qsort( vals, size );                                    $\C{// descending sort}$
    347356}
     
    414423\section{Generic Types}
    415424
    416 One of the known shortcomings of standard C is that it does not provide reusable type-safe abstractions for generic data structures and algorithms.
     425A significant shortcoming of standard C is the lack of reusable type-safe abstractions for generic data structures and algorithms.
    417426Broadly speaking, there are three approaches to implement abstract data-structures in C.
    418427One approach is to write bespoke data-structures for each context in which they are needed.
    419428While 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 for common 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.
     429A 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.
     430However, 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.
    422431A 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.
    423432Furthermore, writing and using preprocessor macros can be unnatural and inflexible.
     
    434443};
    435444forall( 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; }
     445forall( dtype F, otype T ) T value( pair( F *, T * ) p ) { return *p.second; }
    437446
    438447pair( const char *, int ) p = { "magic", 42 };
    439 int magic = value( p );
     448int i = value( p );
    440449pair( void *, int * ) q = { 0, &p.second };
    441 magic = value_p( q );
     450i = value( q );
    442451double d = 1.0;
    443452pair( double *, double * ) r = { &d, &d };
    444 d = value_p( r );
     453d = value( r );
    445454\end{cfa}
    446455
     
    589598[ double ] foo$\(_2\)$( int );
    590599void bar( int, double, double );
    591 bar( foo( 3 ), foo( 3 ) );
     600`bar`( foo( 3 ), foo( 3 ) );
    592601\end{cfa}
    593602The 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.
     
    835844Since @sum@\(_0\) does not accept any arguments, it is not a valid candidate function for the call @sum(10, 20, 30)@.
    836845In 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 unitl @Params@ is bound to @[]@, requiring an assertion @int sum()@, which matches @sum@\(_0\) and terminates the recursion.
     846The process continues until @Params@ is bound to @[]@, requiring an assertion @int sum()@, which matches @sum@\(_0\) and terminates the recursion.
    838847Effectively, 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))@.
    839848
     
    11611170@case@ clauses are made disjoint by the @break@ statement.
    11621171While 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}
     1172For 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}).
     1173Collectively, these enhancements reduce programmer burden and increase readability and safety.
     1174
     1175\begin{figure}
     1176\centering
    11651177\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}}        \\
    11681180\begin{cfa}
    11691181`choose` ( day ) {
     
    11991211\end{tabular}
    12001212\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}
    12031216
    12041217\begin{comment}
     
    13681381\begin{cquote}
    13691382\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}}      \\
    13721385\begin{cfa}
    13731386`exception R { int fix; };`
     
    20672080In many cases, the interface is an inline wrapper providing overloading during compilation but zero cost at runtime.
    20682081The 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.
     2082In 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.
    20702083
    20712084
     
    20992112\begin{cfa}
    21002113MIN
     2114
    21012115MAX
    2102 M_PI
    2103 M_E
     2116
     2117PI
     2118E
    21042119\end{cfa}
    21052120&
    21062121\begin{cfa}
    21072122SCHAR_MIN, CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, LLONG_MIN,
     2123                FLT_MIN, DBL_MIN, LDBL_MIN
    21082124SCHAR_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
     2126M_PI, M_PIl
     2127M_E, M_El
    21112128\end{cfa}
    21122129\end{tabular}
     
    21582175While \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).
    21592176For example, it is impossible to overload @atan@ for both one and two arguments;
    2160 instead the names @atan@ and @atan2@ are required.
     2177instead the names @atan@ and @atan2@ are required (see Section~\ref{s:NameOverloading}).
    21612178The 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.
    21622179
     
    24462463\begin{cfa}[xleftmargin=3\parindentlnth,aboveskip=0pt,belowskip=0pt]
    24472464int 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; )
    24692483}
    24702484\end{cfa}
     
    26402654\CFA
    26412655\begin{cfa}[xleftmargin=2\parindentlnth,aboveskip=0pt,belowskip=0pt]
     2656forall(otype T) struct stack_node;
     2657forall(otype T) struct stack {
     2658        stack_node(T) * head;
     2659};
    26422660forall(otype T) struct stack_node {
    26432661        T value;
    26442662        stack_node(T) * next;
    26452663};
    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;
     2664forall(otype T) void ?{}( stack(T) & s ) { (s.head){ 0 }; }
     2665forall(otype T) void ?{}( stack(T) & s, stack(T) t ) {
     2666        stack_node(T) ** crnt = &s.head;
    26492667        for ( stack_node(T) * next = t.head; next; next = next->next ) {
    2650                 *crnt = ((stack_node(T) *)malloc()){ next->value }; /***/
     2668                *crnt = malloc(){ next->value };
    26512669                stack_node(T) * acrnt = *crnt;
    26522670                crnt = &acrnt->next;
     
    26542672        *crnt = 0;
    26552673}
    2656 forall(otype T) stack(T) ?=?(stack(T) * s, stack(T) t) {
    2657         if ( s->head == t.head ) return *s;
    2658         clear(s);
     2674forall(otype T) stack(T) ?=?( stack(T) & s, stack(T) t ) {
     2675        if ( s.head == t.head ) return s;
     2676        clear( s );
    26592677        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}
     2680forall(otype T) void ^?{}( stack(T) & s) { clear( s ); }
     2681forall(otype T) _Bool empty( const stack(T) & s ) { return s.head == 0; }
     2682forall(otype T) void push( stack(T) & s, T value ) {
     2683        s.head = malloc(){ value, s.head };
     2684}
     2685forall(otype T) T pop( stack(T) & s ) {
     2686        stack_node(T) * n = s.head;
     2687        s.head = n->next;
    26702688        T x = n->value;
    26712689        ^n{};
    2672         free(n);
     2690        free( n );
    26732691        return x;
    26742692}
    2675 forall(otype T) void clear(stack(T) * s) {
    2676         for ( stack_node(T) * next = s->head; next; ) {
     2693forall(otype T) void clear( stack(T) & s ) {
     2694        for ( stack_node(T) * next = s.head; next; ) {
    26772695                stack_node(T) * crnt = next;
    26782696                next = crnt->next;
    2679                 delete(crnt);
     2697                delete( crnt );
    26802698        }
    2681         s->head = 0;
     2699        s.head = 0;
    26822700}
    26832701\end{cfa}
     
    28282846
    28292847\begin{comment}
    2830 
    28312848\subsubsection{bench.h}
    28322849(\texttt{bench.hpp} is similar.)
  • doc/papers/general/evaluation/cfa-bench.c

    r938dd75 r000ff2c  
    1 #include <stdio.h>
     1#include <fstream>
     2#include <stdlib>
    23#include "bench.h"
    34#include "cfa-stack.h"
     
    56#include "cfa-print.h"
    67
    7 int main( int argc, char *argv[] ) {
    8         FILE * out = fopen( "/dev/null", "w" );
    9         int maxi = 0, vali = 42;
    10         stack(int) si, ti;
     8int main( int argc, char * argv[] ) {
     9        ofstream out = { "/dev/null" };
     10        int max = 0, val = 42;
     11        stack( int ) si, t;
    1112
    12         REPEAT_TIMED( "push_int", N, push( si, vali ); )
    13         TIMED( "copy_int", ti = si; )
     13        REPEAT_TIMED( "push_int", N, push( si, val ); )
     14        TIMED( "copy_int", t = si; )
    1415        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; )
    1918
    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;
    2221
    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; )
    3127}
  • doc/papers/general/evaluation/cfa-pair.c

    r938dd75 r000ff2c  
    11#include "cfa-pair.h"
     2#include "fstream"
    23
    3 forall(otype R, otype S 
     4forall(otype R, otype S
    45        | { int ?==?(R, R); int ?<?(R, R); int ?<?(S, S); })
    56int ?<?(pair(R, S) p, pair(R, S) q) {
     
    78}
    89
    9 forall(otype R, otype S 
     10forall(otype R, otype S
    1011        | { int ?==?(R, R); int ?<?(R, R); int ?<=?(S, S); })
    1112int ?<=?(pair(R, S) p, pair(R, S) q) {
     
    2324}
    2425
    25 forall(otype R, otype S 
     26forall(otype R, otype S
    2627        | { int ?==?(R, R); int ?>?(R, R); int ?>?(S, S); })
    2728int ?>?(pair(R, S) p, pair(R, S) q) {
     
    2930}
    3031
    31 forall(otype R, otype S 
     32forall(otype R, otype S
    3233        | { int ?==?(R, R); int ?>?(R, R); int ?>=?(S, S); })
    3334int ?>=?(pair(R, S) p, pair(R, S) q) {
    3435        return p.first > q.first || ( p.first == q.first && p.second >= q.second );
    3536}
     37
     38forall(otype R, otype S)
     39forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, R ); ostype & ?|?( ostype &, S );  })
     40ostype & ?|?( ostype & os, pair(R, S) p ) {
     41        return os | '[' | p.first | ',' | p.second | ']';
     42} // ?|?
  • doc/papers/general/evaluation/cfa-pair.h

    r938dd75 r000ff2c  
    11#pragma once
     2
     3#include "iostream"
    24
    35forall(otype R, otype S) struct pair {
     
    2729        | { int ?==?(R, R); int ?>?(R, R); int ?>=?(S, S); })
    2830int ?>=?(pair(R, S) p, pair(R, S) q);
     31
     32forall(otype R, otype S)
     33forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, pair(R, S) ); })
     34ostype & ?|?( ostype & os, pair(R, S) );
  • doc/papers/general/evaluation/cfa-stack.c

    r938dd75 r000ff2c  
    44forall(otype T) struct stack_node {
    55        T value;
    6         stack_node(T)* next;
     6        stack_node(T) * next;
    77};
     8forall(otype T) void ?{}( stack_node(T) & node, T value, stack_node(T) * next ) {
     9    node.value = value;
     10    node.next = next;
     11}
    812
    9 forall(otype T) void ?{}(stack(T)& s) { (s.head){ 0 }; }
     13forall(otype T) void ?{}( stack(T) & s ) { (s.head){ 0 }; }
    1014
    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 }; /***/
     15forall(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 );
    1519                stack_node(T)* new_node = ((stack_node(T)*)malloc());
    1620                (*new_node){ next->value }; /***/
    1721                *crnt = new_node;
    18 
    19                 stack_node(T)* acrnt = *crnt;
     22                stack_node(T) * acrnt = *crnt;
    2023                crnt = &acrnt->next;
    2124        }
     
    2326}
    2427
    25 forall(otype T) stack(T) ?=?(stack(T)& s, stack(T) t) {
     28forall(otype T) stack(T) ?=?( stack(T) & s, stack(T) t ) {
    2629        if ( s.head == t.head ) return s;
    27         clear(s);
     30        clear( s );
    2831        s{ t };
    2932        return s;
    3033}
    3134
    32 forall(otype T) void ^?{}(stack(T)& s) { clear(s); }
     35forall(otype T) void ^?{}( stack(T) & s) { clear( s ); }
    3336
    34 forall(otype T) _Bool empty(const stack(T)& s) { return s.head == 0; }
     37forall(otype T) _Bool empty( const stack(T) & s ) { return s.head == 0; }
    3538
    36 forall(otype T) void push(stack(T)& s, T value) {
    37         // s.head = &(*(stack_node(T)*)malloc()){ value, s.head }; /***/
     39forall(otype T) void push( stack(T) & s, T value ) {
     40        // s.head = new( value, s.head );
    3841        stack_node(T)* new_node = ((stack_node(T)*)malloc());
    3942        (*new_node){ value, s.head }; /***/
     
    4144}
    4245
    43 forall(otype T) T pop(stack(T)& s) {
    44         stack_node(T)* n = s.head;
     46forall(otype T) T pop( stack(T) & s ) {
     47        stack_node(T) * n = s.head;
    4548        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;
    5052}
    5153
    52 forall(otype T) void clear(stack(T)& s) {
    53     for ( stack_node(T)* next = s.head; next; ) {
    54                 stack_node(T)* crnt = next;
     54forall(otype T) void clear( stack(T) & s ) {
     55        for ( stack_node(T) * next = s.head; next; ) {
     56                stack_node(T) * crnt = next;
    5557                next = crnt->next;
    56                 delete(crnt);
     58                delete( crnt );
    5759        }
    5860        s.head = 0;
  • doc/papers/general/evaluation/cfa-stack.h

    r938dd75 r000ff2c  
    33forall(otype T) struct stack_node;
    44forall(otype T) struct stack {
    5         stack_node(T)* head;
     5        stack_node(T) * head;
    66};
    77
    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);
     8forall(otype T) void ?{}( stack(T) & s );
     9forall(otype T) void ?{}( stack(T) & s, stack(T) t );
     10forall(otype T) stack(T) ?=?( stack(T) & s, stack(T) t );
     11forall(otype T) void ^?{}( stack(T) & s);
    1212
    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);
     13forall(otype T) _Bool empty( const stack(T) & s );
     14forall(otype T) void push( stack(T) & s, T value );
     15forall(otype T) T pop( stack(T) & s );
     16forall(otype T) void clear( stack(T) & s );
  • src/libcfa/limits

    r938dd75 r000ff2c  
    1010// Created On       : Wed Apr  6 18:06:52 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 09:33:57 2017
    13 // Update Count     : 7
     12// Last Modified On : Thu Mar  1 16:20:54 2018
     13// Update Count     : 13
    1414//
    1515
     
    1818// Integral Constants
    1919
     20extern const signed char MIN;
     21extern const unsigned char MIN;
    2022extern const short int MIN;
     23extern const unsigned short int MIN;
    2124extern const int MIN;
     25extern const unsigned int MIN;
    2226extern const long int MIN;
     27extern const unsigned long int MIN;
    2328extern const long long int MIN;
     29extern const unsigned long long int MIN;
    2430
     31extern const signed char MAX;
     32extern const unsigned char MAX;
    2533extern const short int MAX;
    2634extern const unsigned short int MAX;
     
    3341
    3442// Floating-Point Constants
     43
     44extern const float MIN;
     45extern const double MIN;
     46extern const long double MIN;
     47extern const float _Complex MIN;
     48extern const double _Complex MIN;
     49extern const long double _Complex MIN;
     50
     51extern const float MAX;
     52extern const double MAX;
     53extern const long double MAX;
     54extern const float _Complex MAX;
     55extern const double _Complex MAX;
     56extern const long double _Complex MAX;
    3557
    3658extern const float PI;                                                                  // pi
     
    5577extern const long double _2_SQRT_PI;                                    // 2 / sqrt(pi)
    5678
    57 extern const _Complex PI;                                                               // pi
    58 extern const _Complex PI_2;                                                             // pi / 2
    59 extern const _Complex PI_4;                                                             // pi / 4
    60 extern const _Complex _1_PI;                                                    // 1 / pi
    61 extern const _Complex _2_PI;                                                    // 2 / pi
    62 extern const _Complex _2_SQRT_PI;                                               // 2 / sqrt(pi)
     79extern const float _Complex PI;                                                 // pi
     80extern const float _Complex PI_2;                                               // pi / 2
     81extern const float _Complex PI_4;                                               // pi / 4
     82extern const float _Complex _1_PI;                                              // 1 / pi
     83extern const float _Complex _2_PI;                                              // 2 / pi
     84extern const float _Complex _2_SQRT_PI;                                 // 2 / sqrt(pi)
    6385
    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)
     86extern const double _Complex PI;                                                // pi
     87extern const double _Complex PI_2;                                              // pi / 2
     88extern const double _Complex PI_4;                                              // pi / 4
     89extern const double _Complex _1_PI;                                             // 1 / pi
     90extern const double _Complex _2_PI;                                             // 2 / pi
     91extern const double _Complex _2_SQRT_PI;                                // 2 / sqrt(pi)
     92
     93extern const long double _Complex PI;                                   // pi
     94extern const long double _Complex PI_2;                                 // pi / 2
     95extern const long double _Complex PI_4;                                 // pi / 4
     96extern const long double _Complex _1_PI;                                // 1 / pi
     97extern const long double _Complex _2_PI;                                // 2 / pi
     98extern const long double _Complex _2_SQRT_PI;                   // 2 / sqrt(pi)
    7099
    71100extern const float E;                                                                   // e
     
    93122extern const long double _1_SQRT_2;                                             // 1/sqrt(2)
    94123
    95 extern const _Complex E;                                                                // e
    96 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)
     124extern const float _Complex E;                                                  // e
     125extern const float _Complex LOG2_E;                                             // log_2(e)
     126extern const float _Complex LOG10_E;                                    // log_10(e)
     127extern const float _Complex LN_2;                                               // log_e(2)
     128extern const float _Complex LN_10;                                              // log_e(10)
     129extern const float _Complex SQRT_2;                                             // sqrt(2)
     130extern const float _Complex _1_SQRT_2;                                  // 1 / sqrt(2)
    102131
    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)
     132extern const double _Complex E;                                                 // e
     133extern const double _Complex LOG2_E;                                    // log_2(e)
     134extern const double _Complex LOG10_E;                                   // log_10(e)
     135extern const double _Complex LN_2;                                              // log_e(2)
     136extern const double _Complex LN_10;                                             // log_e(10)
     137extern const double _Complex SQRT_2;                                    // sqrt(2)
     138extern const double _Complex _1_SQRT_2;                                 // 1 / sqrt(2)
     139
     140extern const long double _Complex E;                                    // e
     141extern const long double _Complex LOG2_E;                               // log_2(e)
     142extern const long double _Complex LOG10_E;                              // log_10(e)
     143extern const long double _Complex LN_2;                                 // log_e(2)
     144extern const long double _Complex LN_10;                                // log_e(10)
     145extern const long double _Complex SQRT_2;                               // sqrt(2)
     146extern const long double _Complex _1_SQRT_2;                    // 1 / sqrt(2)
    110147
    111148// Local Variables: //
  • src/libcfa/limits.c

    r938dd75 r000ff2c  
    1010// Created On       : Wed Apr  6 18:06:52 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 12 10:34:48 2016
    13 // Update Count     : 17
     12// Last Modified On : Thu Mar  1 16:22:51 2018
     13// Update Count     : 74
    1414//
    1515
     16#include <limits.h>
     17#include <float.h>
     18#define __USE_GNU                                                                               // get M_* constants
     19#include <math.h>
     20#include <complex.h>
    1621#include "limits"
    1722
    1823// Integral Constants
    1924
    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;
     25const signed char MIN = SCHAR_MIN;
     26const unsigned char MIN = 0;
     27const short int MIN = SHRT_MIN;
     28const unsigned short int MIN = 0;
     29const int MIN = INT_MIN;
     30const unsigned int MIN = 0;
     31const long int MIN = LONG_MIN;
     32const unsigned long int MIN = 0;
     33const long long int MIN = LLONG_MIN;
     34const unsigned long long int MIN = 0;
    2835
    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;
     36const signed char MAX = SCHAR_MAX;
     37const unsigned char MAX = UCHAR_MAX;
     38const short int MAX = SHRT_MAX;
     39const unsigned short int MAX = USHRT_MAX;
     40const int MAX = INT_MAX;
     41const unsigned int MAX = UINT_MAX;
     42const long int MAX = LONG_MAX;
     43const unsigned long int MAX = ULONG_MAX;
     44const long long int MAX = LLONG_MAX;
     45const unsigned long long int MAX = ULLONG_MAX;
    4146
    4247// Floating-Point Constants
    4348
    44 const float PI = 3.141592_F;                                                    // pi
    45 const float PI_2 = 1.570796_F;                                                  // pi / 2
    46 const float PI_4 = 0.7853981_F;                                                 // pi / 4
    47 const float _1_PI = 0.3183098_F;                                                // 1 / pi
    48 const float _2_PI = 0.6366197_F;                                                // 2 / pi
    49 const float _2_SQRT_PI = 1.128379_F;                                    // 2 / sqrt(pi)
     49const float MIN = FLT_MIN;
     50const double MIN = DBL_MIN;
     51const long double MIN = LDBL_MIN;
     52const float _Complex MIN = __FLT_MIN__ + __FLT_MIN__ * I;
     53const double _Complex MIN = DBL_MIN +  DBL_MIN * I;
     54const long double _Complex MIN = LDBL_MIN + LDBL_MIN * I;
    5055
    51 const double PI = 3.14159265358979323846_D;                             // pi
    52 const double PI_2 = 1.57079632679489661923_D;                   // pi / 2
    53 const double PI_4 = 0.78539816339744830962_D;                   // pi / 4
    54 const double _1_PI = 0.31830988618379067154_D;                  // 1 / pi
    55 const double _2_PI = 0.63661977236758134308_D;                  // 2 / pi
    56 const double _2_SQRT_PI = 1.12837916709551257390_D;             // 2 / sqrt(pi)
     56const float MAX = FLT_MAX;
     57const double MAX = DBL_MAX;
     58const long double MAX = LDBL_MAX;
     59const float _Complex MAX = FLT_MAX + FLT_MAX * I;
     60const double _Complex MAX = DBL_MAX + DBL_MAX * I;
     61const long double _Complex MAX = LDBL_MAX + LDBL_MAX * I;
    5762
    58 const long double PI = 3.1415926535897932384626433832795029_DL; // pi
    59 const long double PI_2 = 1.5707963267948966192313216916397514_DL; // pi / 2
    60 const long double PI_4 = 0.7853981633974483096156608458198757_DL; // pi / 4
    61 const long double _1_PI = 0.3183098861837906715377675267450287_DL; // 1 / pi
    62 const long double _2_PI = 0.6366197723675813430755350534900574_DL; // 2 / pi
    63 const long double _2_SQRT_PI = 1.1283791670955125738961589031215452_DL; // 2 / sqrt(pi)
     63const float PI = (float)M_PI;                                                   // pi
     64const float PI_2 = (float)M_PI_2;                                               // pi / 2
     65const float PI_4 = (float)M_PI_4;                                               // pi / 4
     66const float _1_PI = (float)M_1_PI;                                              // 1 / pi
     67const float _2_PI = (float)M_2_PI;                                              // 2 / pi
     68const float _2_SQRT_PI = (float)M_2_SQRTPI;                             // 2 / sqrt(pi)
    6469
    65 const double _Complex PI = 3.14159265358979323846_D+0.0_iD;     // pi
    66 const double _Complex PI_2 = 1.57079632679489661923_D+0.0_iD; // pi / 2
    67 const double _Complex PI_4 = 0.78539816339744830962_D+0.0_iD; // pi / 4
    68 const double _Complex _1_PI = 0.31830988618379067154_D+0.0_iD; // 1 / pi
    69 const double _Complex _2_PI = 0.63661977236758134308_D+0.0_iD; // 2 / pi
    70 const double _Complex _2_SQRT_PI = 1.12837916709551257390_D+0.0_iD; // 2 / sqrt(pi)
     70const double PI = M_PI;                                                                 // pi
     71const double PI_2 = M_PI_2;                                                             // pi / 2
     72const double PI_4 = M_PI_4;                                                             // pi / 4
     73const double _1_PI = M_1_PI;                                                    // 1 / pi
     74const double _2_PI = M_2_PI;                                                    // 2 / pi
     75const double _2_SQRT_PI = M_2_SQRTPI;                                   // 2 / sqrt(pi)
    7176
    72 const long double _Complex PI = 3.1415926535897932384626433832795029_L+0.0iL; // pi
    73 const long double _Complex PI_2 = 1.5707963267948966192313216916397514_L+0.0iL; // pi / 2
    74 const long double _Complex PI_4 = 0.7853981633974483096156608458198757_L+0.0iL; // pi / 4
    75 const long double _Complex _1_PI = 0.3183098861837906715377675267450287_L+0.0iL; // 1 / pi
    76 const long double _Complex _2_PI = 0.6366197723675813430755350534900574_L+0.0iL; // 2 / pi
    77 const long double _Complex _2_SQRT_PI = 1.1283791670955125738961589031215452_L+0.0iL; // 2 / sqrt(pi)
     77const long double PI = M_PIl;                                                   // pi
     78const long double PI_2 = M_PI_2l;                                               // pi / 2
     79const long double PI_4 = M_PI_4l;                                               // pi / 4
     80const long double _1_PI = M_1_PIl;                                              // 1 / pi
     81const long double _2_PI = M_2_PIl;                                              // 2 / pi
     82const long double _2_SQRT_PI = M_2_SQRTPIl;                             // 2 / sqrt(pi)
    7883
    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)
     84const float _Complex PI = (float)M_PI + 0.0_iF;                 // pi
     85const float _Complex PI_2 = (float)M_PI_2 + 0.0_iF;             // pi / 2
     86const float _Complex PI_4 = (float)M_PI_4 + 0.0_iF;             // pi / 4
     87const float _Complex _1_PI = (float)M_1_PI + 0.0_iF;    // 1 / pi
     88const float _Complex _2_PI = (float)M_2_PI + 0.0_iF;    // 2 / pi
     89const float _Complex _2_SQRT_PI = (float)M_2_SQRTPI + 0.0_iF; // 2 / sqrt(pi)
    8690
    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)
     91const double _Complex PI = M_PI + 0.0_iD;                               // pi
     92const double _Complex PI_2 = M_PI_2 + 0.0_iD;                   // pi / 2
     93const double _Complex PI_4 = M_PI_4 + 0.0_iD;                   // pi / 4
     94const double _Complex _1_PI = M_1_PI + 0.0_iD;                  // 1 / pi
     95const double _Complex _2_PI = M_2_PI + 0.0_iD;                  // 2 / pi
     96const double _Complex _2_SQRT_PI = M_2_SQRTPI + 0.0_iD; // 2 / sqrt(pi)
    9497
    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)
     98const long double _Complex PI = M_PIl + 0.0_iL;                 // pi
     99const long double _Complex PI_2 = M_PI_2l + 0.0_iL;             // pi / 2
     100const long double _Complex PI_4 = M_PI_4l + 0.0_iL;             // pi / 4
     101const long double _Complex _1_PI = M_1_PIl + 0.0_iL;    // 1 / pi
     102const long double _Complex _2_PI = M_2_PIl + 0.0_iL;    // 2 / pi
     103const long double _Complex _2_SQRT_PI = M_2_SQRTPIl + 0.0_iL; // 2 / sqrt(pi)
    102104
    103 const double _Complex E = 2.7182818284590452354_D+0.0_iD; // e
    104 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)
     105const float E = (float)M_E;                                                             // e
     106const float LOG2_E = (float)M_LOG2E;                                    // log_2(e)
     107const float LOG10_E = (float)M_LOG10E;                                  // log_10(e)
     108const float LN_2 = (float)M_LN2;                                                // log_e(2)
     109const float LN_10 = (float)M_LN10;                                              // log_e(10)
     110const float SQRT_2 = (float)M_SQRT2;                                    // sqrt(2)
     111const float _1_SQRT_2 = (float)M_SQRT1_2;                               // 1 / sqrt(2)
    110112
    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)
     113const double E = M_E;                                                                   // e
     114const double LOG2_E = M_LOG2E;                                                  // log_2(e)
     115const double LOG10_E = M_LOG10E;                                                // log_10(e)
     116const double LN_2 = M_LN2;                                                              // log_e(2)
     117const double LN_10 = M_LN10;                                                    // log_e(10)
     118const double SQRT_2 = M_SQRT2;                                                  // sqrt(2)
     119const double _1_SQRT_2 = M_SQRT1_2;                                             // 1 / sqrt(2)
     120
     121const long double E = M_El;                                                             // e
     122const long double LOG2_E = M_LOG2El;                                    // log_2(e)
     123const long double LOG10_E = M_LOG10El;                                  // log_10(e)
     124const long double LN_2 = M_LN2l;                                                // log_e(2)
     125const long double LN_10 = M_LN10l;                                              // log_e(10)
     126const long double SQRT_2 = M_SQRT2l;                                    // sqrt(2)
     127const long double _1_SQRT_2 = M_SQRT1_2l;                               // 1 / sqrt(2)
     128
     129const float _Complex E = M_E + 0.0_iF;                                  // e
     130const float _Complex LOG2_E = M_LOG2E + 0.0_iF;                 // log_2(e)
     131const float _Complex LOG10_E = M_LOG10E + 0.0_iF;               // log_10(e)
     132const float _Complex LN_2 = M_LN2 + 0.0_iF;                             // log_e(2)
     133const float _Complex LN_10 = M_LN10 + 0.0_iF;                   // log_e(10)
     134const float _Complex SQRT_2 = M_SQRT2 + 0.0_iF;                 // sqrt(2)
     135const float _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iF;    // 1 / sqrt(2)
     136
     137const double _Complex E = M_E + 0.0_iD;                                 // e
     138const double _Complex LOG2_E = M_LOG2E + 0.0_iD;                // log_2(e)
     139const double _Complex LOG10_E = M_LOG10E + 0.0_iD;              // log_10(e)
     140const double _Complex LN_2 = M_LN2 + 0.0_iD;                    // log_e(2)
     141const double _Complex LN_10 = M_LN10 + 0.0_iD;                  // log_e(10)
     142const double _Complex SQRT_2 = M_SQRT2 + 0.0_iD;                // sqrt(2)
     143const double _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iD;   // 1 / sqrt(2)
     144
     145const long double _Complex E = M_El + 0.0_iL;                   // e
     146const long double _Complex LOG2_E = M_LOG2El + 0.0_iL;  // log_2(e)
     147const long double _Complex LOG10_E = M_LOG10El + 0.0_iL; // log_10(e)
     148const long double _Complex LN_2 = M_LN2l + 0.0_iL;              // log_e(2)
     149const long double _Complex LN_10 = M_LN10l + 0.0_iL;    // log_e(10)
     150const long double _Complex SQRT_2 = M_SQRT2l + 0.0_iL;  // sqrt(2)
     151const long double _Complex _1_SQRT_2 = M_SQRT1_2l + 0.0_iL; // 1 / sqrt(2)
    118152
    119153// Local Variables: //
  • src/tests/limits.c

    r938dd75 r000ff2c  
    1010// Created On       : Tue May 10 20:44:20 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 10 20:45:28 2016
    13 // Update Count     : 1
     12// Last Modified On : Thu Mar  1 16:21:55 2018
     13// Update Count     : 7
    1414//
    1515
     
    1818// Integral Constants
    1919
     20signed char m = MIN;
     21unsigned char m = MIN;
    2022short int m = MIN;
     23unsigned short int m = MIN;
    2124int m = MIN;
     25unsigned int m = MIN;
    2226long int m = MIN;
     27unsigned long int m = MIN;
    2328long long int m = MIN;
     29unsigned long long int m = MIN;
    2430
     31signed char M = MAX;
     32unsigned char M = MAX;
    2533short int M = MAX;
    2634unsigned short int M = MAX;
     
    3341
    3442// Floating-Point Constants
     43
     44float m = MIN;
     45double m = MIN;
     46long double m = MIN;
     47float _Complex m = MIN;
     48double _Complex m = MIN;
     49long double _Complex m = MIN;
     50
     51float M = MAX;
     52double M = MAX;
     53long double M = MAX;
     54float _Complex M = MAX;
     55double _Complex M = MAX;
     56long double _Complex M = MAX;
    3557
    3658float pi = PI;
     
    5577long double _2_sqrt_pi = _2_SQRT_PI;
    5678
    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;
     79float _Complex pi = PI;
     80float _Complex pi_2 = PI_2;
     81float _Complex pi_4 = PI_4;
     82float _Complex _1_pi = _1_PI;
     83float _Complex _2_pi = _2_PI;
     84float _Complex _2_sqrt_pi = _2_SQRT_PI;
    6385
    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;
     86double _Complex pi = PI;
     87double _Complex pi_2 = PI_2;
     88double _Complex pi_4 = PI_4;
     89double _Complex _1_pi = _1_PI;
     90double _Complex _2_pi = _2_PI;
     91double _Complex _2_sqrt_pi = _2_SQRT_PI;
     92
     93long double _Complex pi = PI;
     94long double _Complex pi_2 = PI_2;
     95long double _Complex pi_4 = PI_4;
     96long double _Complex _1_pi = _1_PI;
     97long double _Complex _2_pi = _2_PI;
     98long double _Complex _2_sqrt_pi = _2_SQRT_PI;
    7099
    71100float e = E;
     
    93122long double _1_sqrt_2 = _1_SQRT_2;
    94123
    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;
     124float _Complex e = E;
     125float _Complex log2_e = LOG2_E;
     126float _Complex log10_e = LOG10_E;
     127float _Complex ln_2 = LN_2;
     128float _Complex ln_10 = LN_10;
     129float _Complex sqrt_2 = SQRT_2;
     130float _Complex _1_sqrt_2 = _1_SQRT_2;
    102131
    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;
     132double _Complex e = E;
     133double _Complex log2_e = LOG2_E;
     134double _Complex log10_e = LOG10_E;
     135double _Complex ln_2 = LN_2;
     136double _Complex ln_10 = LN_10;
     137double _Complex sqrt_2 = SQRT_2;
     138double _Complex _1_sqrt_2 = _1_SQRT_2;
     139
     140long double _Complex e = E;
     141long double _Complex log2_e = LOG2_E;
     142long double _Complex log10_e = LOG10_E;
     143long double _Complex ln_2 = LN_2;
     144long double _Complex ln_10 = LN_10;
     145long double _Complex sqrt_2 = SQRT_2;
     146long double _Complex _1_sqrt_2 = _1_SQRT_2;
    110147
    111148int main(int argc, char const *argv[]) {
Note: See TracChangeset for help on using the changeset viewer.