Changeset 6e991d6


Ignore:
Timestamp:
Apr 21, 2016, 8:24:07 AM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, string, with_gc
Children:
6812d89
Parents:
6b6597c
Message:

add -fgnu89-inline flag to compile, cleanup swap example I/O, stdlib fixes, start math library

Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r6b6597c r6e991d6  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Thu Apr 14 21:30:07 2016
    14 %% Update Count     : 130
     13%% Last Modified On : Thu Apr 21 08:15:37 2016
     14%% Update Count     : 131
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    240240\index{-std=gnu99@{\lstinline$-std=gnu99$}}\index{compilation option!-std=gnu99@{\lstinline$-std=gnu99$}}
    241241The 1999 C standard plus GNU extensions.
     242\item
     243\hspace*{-4pt}\lstinline@-fgnu89-inline@
     244\index{-fgnu89-inline@{\lstinline$-fgnu89-inline$}}\index{compilation option!-fgnu89-inline@{\lstinline$-fgnu89-inline$}}
     245Use the traditional GNU semantics for inline routines in C99 mode.
    242246\end{description}
    243247The following new \CFA option is available:
  • src/driver/cfa.cc

    r6b6597c r6e991d6  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr  6 14:04:22 2016
    13 // Update Count     : 132
     12// Last Modified On : Wed Apr 20 18:31:28 2016
     13// Update Count     : 133
    1414//
    1515
     
    310310                        nargs += 1;
    311311                } // if
     312                args[nargs] = "-fgnu89-inline";
     313                nargs += 1;
    312314                args[nargs] = ( *new string( string("-B") + Bprefix + "/" ) ).c_str();
    313315                nargs += 1;
  • src/examples/swap.c

    r6b6597c r6e991d6  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 16:15:11 2016
    13 // Update Count     : 65
     12// Last Modified On : Thu Apr 21 08:10:41 2016
     13// Update Count     : 69
    1414//
    1515
     
    2424
    2525        signed int i1 = -1, i2 = -2;
    26         sout | "signed int\t\t" | i1 | ' ' | i2 | "\t\t\tswap ";
     26        sout | "signed int\t\t" | i1 | i2 | "\t\t\tswap ";
    2727        swap( &i1, &i2 );
    28         sout | '\t' | i1 | ' ' | i2 | endl;
     28        sout | '\t' | i1 | i2 | endl;
    2929
    3030        unsigned int ui1 = 1, ui2 = 2;
    31         sout | "unsigned int\t\t" | ui1 | ' ' | ui2 | "\t\t\tswap ";
     31        sout | "unsigned int\t\t" | ui1 | ui2 | "\t\t\tswap ";
    3232        swap( &ui1, &ui2 );
    33         sout | '\t' | ui1 | ' ' | ui2 | endl;
     33        sout | '\t' | ui1 | ui2 | endl;
    3434
    3535        signed long int li1 = -1, li2 = -2;
    36         sout | "signed long int\t\t" | li1 | ' ' | li2 | "\t\t\tswap ";
     36        sout | "signed long int\t\t" | li1 | li2 | "\t\t\tswap ";
    3737        swap( &li1, &li2 );
    38         sout | '\t' | li1 | ' ' | li2 | endl;
     38        sout | '\t' | li1 | li2 | endl;
    3939
    4040        unsigned long int uli1 = 1, uli2 = 2;
    41         sout | "unsigned long int\t" | uli1 | ' ' | uli2 | "\t\t\tswap ";
     41        sout | "unsigned long int\t" | uli1 | uli2 | "\t\t\tswap ";
    4242        swap( &uli1, &uli2 );
    43         sout | '\t' | uli1 | ' ' | uli2 | endl;
     43        sout | '\t' | uli1 | uli2 | endl;
    4444
    4545        signed long long int lli1 = -1, lli2 = -2;
    46         sout | "signed long long int\t" | lli1 | ' ' | lli2 | "\t\t\tswap ";
     46        sout | "signed long long int\t" | lli1 | lli2 | "\t\t\tswap ";
    4747        swap( &lli1, &lli2 );
    48         sout | '\t' | lli1 | ' ' | lli2 | endl;
     48        sout | '\t' | lli1 | lli2 | endl;
    4949
    5050        unsigned long long int ulli1 = 1, ulli2 = 2;
    51         sout | "unsigned long long int\t" | ulli1 | ' ' | ulli2 | "\t\t\tswap ";
     51        sout | "unsigned long long int\t" | ulli1 | ulli2 | "\t\t\tswap ";
    5252        swap( &ulli1, &ulli2 );
    53         sout | '\t' | ulli1 | ' ' | ulli2 | endl;
     53        sout | '\t' | ulli1 | ulli2 | endl;
    5454
    5555        float f1 = 1.5, f2 = 2.5;
    56         sout | "float\t\t\t" | f1 | ' ' | f2 | "\t\tswap ";
     56        sout | "float\t\t\t" | f1 | f2 | "\t\t\tswap ";
    5757        swap( &f1, &f2 );
    58         sout | '\t' | f1 | ' ' | f2 | endl;
     58        sout | '\t' | f1 | f2 | endl;
    5959
    6060        double d1 = 1.5, d2 = 2.5;
    61         sout | "double\t\t\t" | d1 | ' ' | d2 | "\t\tswap ";
     61        sout | "double\t\t\t" | d1 | d2 | "\t\t\tswap ";
    6262        swap( &d1, &d2 );
    63         sout | '\t' | d1 | ' ' | d2 | endl;
     63        sout | '\t' | d1 | d2 | endl;
    6464
    6565        long double ld1 = 1.5, ld2 = 2.5;
    66         sout | "long double\t\t" | ld1 | ' ' | ld2 | "\t\tswap ";
     66        sout | "long double\t\t" | ld1 | ld2 | "\t\t\tswap ";
    6767        swap( &ld1, &ld2 );
    68         sout | '\t' | ld1 | ' ' | ld2 | endl;
     68        sout | '\t' | ld1 | ld2 | endl;
    6969
    7070        float _Complex fc1 = 1.5f+1.5if, fc2 = 2.5f+2.5if;
    71         sout | "float _Complex\t\t" | fc1 | ' ' | fc2 | "\tswap ";
     71        sout | "float _Complex\t\t" | fc1 | fc2 | "\tswap ";
    7272        swap( &fc1, &fc2 );
    73         sout | '\t' | fc1 | ' ' | fc2 | endl;
     73        sout | '\t' | fc1 | fc2 | endl;
    7474
    7575        double _Complex dc1 = 1.5d+1.5id, dc2 = 2.5d+2.5id;
    76         sout | "double _Complex\t\t" | dc1 | ' ' | dc2 | "\tswap ";
     76        sout | "double _Complex\t\t" | dc1 | dc2 | "\tswap ";
    7777        swap( &dc1, &dc2 );
    78         sout | '\t' | dc1 | ' ' | dc2 | endl;
     78        sout | '\t' | dc1 | dc2 | endl;
    7979
    8080        long double _Complex ldc1 = 1.5d+1.5il, ldc2 = 2.5d+2.5il;
    81         sout | "long double _Complex\t" | ldc1 | ' ' | ldc2 | "\tswap ";
     81        sout | "long double _Complex\t" | ldc1 | ldc2 | "\tswap ";
    8282        swap( &ldc1, &ldc2 );
    83         sout | '\t' | ldc1 | ' ' | ldc2 | endl;
     83        sout | '\t' | ldc1 | ldc2 | endl;
    8484
    8585        struct S { int i, j; } s1 = { 1, 2 }, s2 = { 2, 1 };
    86         ofstream * ?|?( ofstream * os, S s ) { return os | s.i | ' ' | s.j; }
    87         sout | "struct S\t\t" | s1 | "  " | s2 | "\t\tswap ";
     86        ofstream * ?|?( ofstream * os, S s ) { return os | s.i | s.j; }
     87        sout | "struct S\t\t" | s1 | "," | s2 | "\t\tswap ";
    8888        swap( &s1, &s2 );
    89         sout | '\t' | s1 | "  " | s2 | endl;
     89        sout | '\t' | s1 | "," | s2 | endl;
    9090} // main
    9191
  • src/libcfa/Makefile.am

    r6b6597c r6e991d6  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Wed Apr  6 21:10:44 2016
    14 ## Update Count     : 123
     13## Last Modified On : Tue Apr 19 22:30:17 2016
     14## Update Count     : 124
    1515###############################################################################
    1616
     
    6060        ${CC} ${CFLAGS} -c -o $@ $<
    6161
    62 libs = limits stdlib iostream fstream iterator rational
     62libs = limits stdlib math iostream fstream iterator rational
    6363libcfa_a_SOURCES = libcfa-prelude.c ${libs:=.c}
    6464
  • src/libcfa/Makefile.in

    r6b6597c r6e991d6  
    8383libcfa_a_AR = $(AR) $(ARFLAGS)
    8484libcfa_a_LIBADD =
    85 am__objects_1 = limits.$(OBJEXT) stdlib.$(OBJEXT) iostream.$(OBJEXT) \
    86         fstream.$(OBJEXT) iterator.$(OBJEXT) rational.$(OBJEXT)
     85am__objects_1 = limits.$(OBJEXT) stdlib.$(OBJEXT) math.$(OBJEXT) \
     86        iostream.$(OBJEXT) fstream.$(OBJEXT) iterator.$(OBJEXT) \
     87        rational.$(OBJEXT)
    8788am_libcfa_a_OBJECTS = libcfa-prelude.$(OBJEXT) $(am__objects_1)
    8889libcfa_a_OBJECTS = $(am_libcfa_a_OBJECTS)
     
    213214MAINTAINERCLEANFILES = ${addprefix ${libdir}/,${cfalib_DATA}} \
    214215        ${addprefix ${libdir}/,${lib_LIBRARIES}} ${includedir}/*
    215 libs = limits stdlib iostream fstream iterator rational
     216libs = limits stdlib math iostream fstream iterator rational
    216217libcfa_a_SOURCES = libcfa-prelude.c ${libs:=.c}
    217218cheaders = # expat
     
    298299@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa-prelude.Po@am__quote@
    299300@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/limits.Po@am__quote@
     301@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/math.Po@am__quote@
    300302@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rational.Po@am__quote@
    301303@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdlib.Po@am__quote@
  • src/libcfa/rational.c

    r6b6597c r6e991d6  
    1111// Created On       : Wed Apr  6 17:54:28 2016
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Tue Apr 12 21:26:42 2016
    14 // Update Count     : 21
     13// Last Modified On : Thu Apr 21 07:33:03 2016
     14// Update Count     : 22
    1515//
    1616
     
    1818#include "fstream"
    1919#include "stdlib"
     20#include "math"                                                                                 // floor
    2021
    2122
  • src/libcfa/stdlib

    r6b6597c r6e991d6  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 19 21:21:53 2016
    13 // Update Count     : 93
     12// Last Modified On : Thu Apr 21 07:55:21 2016
     13// Update Count     : 95
    1414//
    1515
     
    3333//---------------------------------------
    3434
    35 extern "C" {
    36 void * malloc( size_t );                                                                // use default C routine for void *
    37 } // extern "C"
     35extern "C" { void * malloc( size_t ); }                                 // use default C routine for void *
    3836forall( otype T ) T * malloc( void );
    3937forall( otype T ) T * malloc( char fill );
    4038forall( otype T ) T * malloc( T * ptr, size_t size );
    4139forall( otype T ) T * malloc( T * ptr, size_t size, unsigned char fill );
    42 extern "C" {
    43 void * calloc( size_t nmemb, size_t size );                             // use default C routine for void *
    44 } // extern "C"
     40extern "C" { void * calloc( size_t nmemb, size_t size ); } // use default C routine for void *
    4541forall( otype T ) T * calloc( size_t nmemb );
    46 extern "C" {
    47 void * realloc( void * ptr, size_t size );                              // use default C routine for void *
    48 } // extern "C"
     42extern "C" { void * realloc( void * ptr, size_t size ); } // use default C routine for void *
    4943forall( otype T ) T * realloc( T * ptr, size_t size );
    5044forall( otype T ) T * realloc( T * ptr, size_t size, unsigned char fill );
     
    10397
    10498char abs( char );
    105 extern "C" {
    106 int abs( int );                                                                                 // use default C routine for int
    107 } // extern "C"
     99extern "C" { int abs( int ); }                                                  // use default C routine for int
    108100long int abs( long int );
    109101long long int abs( long long int );
     
    111103double abs( double );
    112104long double abs( long double );
    113 float _Complex abs( float _Complex );
    114 double _Complex abs( double _Complex );
    115 long double _Complex abs( long double _Complex );
    116 
    117 //---------------------------------------
    118 
    119 float floor( float );
    120 extern "C" {
    121 double floor( double );                                                                 // use C routine for double
    122 } // extern "C"
    123 long double floor( long double );
    124 
    125 float ceil( float );
    126 extern "C" {
    127 double ceil( double );                                                                  // use C routine for double
    128 } // extern "C"
    129 long double ceil( long double );
     105float abs( float _Complex );
     106double abs( double _Complex );
     107long double abs( long double _Complex );
    130108
    131109//---------------------------------------
  • src/libcfa/stdlib.c

    r6b6597c r6e991d6  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 19 21:21:51 2016
    13 // Update Count     : 159
     12// Last Modified On : Thu Apr 21 07:58:29 2016
     13// Update Count     : 165
    1414//
    1515
     
    2424#include <malloc.h>                                                                             // malloc_usable_size
    2525#include <math.h>                                                                               // fabsf, fabs, fabsl
    26 #include <complex.h>                                                                    // _Complex_I, cabsf, cabs, cabsl
     26#include <complex.h>                                                                    // _Complex_I
    2727} // extern "C"
    2828
     
    8282int ato( const char * ptr ) {
    8383        int i;
    84         if ( sscanf( ptr, "%d", &i ) == EOF ) {}                        // check return code
     84        if ( sscanf( ptr, "%d", &i ) == EOF ) {}
    8585        return i;
    8686}
    8787unsigned int ato( const char * ptr ) {
    8888        unsigned int ui;
    89         if ( sscanf( ptr, "%u", &ui ) == EOF ) {}                       // check return code
     89        if ( sscanf( ptr, "%u", &ui ) == EOF ) {}
    9090        return ui;
    9191}
    9292long int ato( const char * ptr ) {
    9393        long int li;
    94         if ( sscanf( ptr, "%ld", &li ) == EOF ) {}                      // check return code
     94        if ( sscanf( ptr, "%ld", &li ) == EOF ) {}
    9595        return li;
    9696}
    9797unsigned long int ato( const char * ptr ) {
    9898        unsigned long int uli;
    99         if ( sscanf( ptr, "%lu", &uli ) == EOF ) {}                     // check return code
     99        if ( sscanf( ptr, "%lu", &uli ) == EOF ) {}
    100100        return uli;
    101101}
    102102long long int ato( const char * ptr ) {
    103103        long long int lli;
    104         if ( sscanf( ptr, "%lld", &lli ) == EOF ) {}            // check return code
     104        if ( sscanf( ptr, "%lld", &lli ) == EOF ) {}
    105105        return lli;
    106106}
    107107unsigned long long int ato( const char * ptr ) {
    108108        unsigned long long int ulli;
    109         if ( sscanf( ptr, "%llu", &ulli ) == EOF ) {}           // check return code
     109        if ( sscanf( ptr, "%llu", &ulli ) == EOF ) {}
    110110        return ulli;
    111111}
     
    113113float ato( const char * ptr ) {
    114114        float f;
    115         if ( sscanf( ptr, "%f", &f ) == EOF ) {}                        // check return code
     115        if ( sscanf( ptr, "%f", &f ) == EOF ) {}
    116116        return f;
    117117}
    118118double ato( const char * ptr ) {
    119119        double d;
    120         if ( sscanf( ptr, "%lf", &d ) == EOF ) {}                       // check return code
     120        if ( sscanf( ptr, "%lf", &d ) == EOF ) {}
    121121        return d;
    122122}
    123123long double ato( const char * ptr ) {
    124124        long double ld;
    125         if ( sscanf( ptr, "%Lf", &ld ) == EOF ) {}                      // check return code
     125        if ( sscanf( ptr, "%Lf", &ld ) == EOF ) {}
    126126        return ld;
    127127}
     
    129129float _Complex ato( const char * ptr ) {
    130130        float re, im;
    131         if ( sscanf( ptr, "%g%gi", &re, &im ) == EOF ) {}       // check return code
     131        if ( sscanf( ptr, "%g%gi", &re, &im ) == EOF ) {}
    132132        return re + im * _Complex_I;
    133133}
    134134double _Complex ato( const char * ptr ) {
    135135        double re, im;
    136         if ( sscanf( ptr, "%lf%lfi", &re, &im ) == EOF ) {} // check return code
     136        if ( sscanf( ptr, "%lf%lfi", &re, &im ) == EOF ) {}
    137137        return re + im * _Complex_I;
    138138}
    139139long double _Complex ato( const char * ptr ) {
    140140        long double re, im;
    141         if ( sscanf( ptr, "%Lf%Lfi", &re, &im ) == EOF ) {}     // check return code
     141        if ( sscanf( ptr, "%Lf%Lfi", &re, &im ) == EOF ) {}
    142142        return re + im * _Complex_I;
    143143}       
     
    221221long int abs( long int v ) { return labs( v ); }
    222222long long int abs( long long int v ) { return llabs( v ); }
    223 float abs( float v ) { return fabsf( v ); }
    224 double abs( double v ) { return fabs( v ); }
    225 long double abs( long double v ) { return fabsl( v ); }
    226 float _Complex abs( float _Complex v ) { return cabsf( v ); }
    227 double _Complex abs( double _Complex v ) { return cabs( v ); }
    228 long double _Complex abs( long double _Complex v ) { return cabsl( v ); }
    229 
    230 //---------------------------------------
    231 
    232 float floor( float v ) { return floorf( v ); }
    233 long double floor( long double v ) { return floorl( v ); }
    234 
    235 float ceil( float v ) { return ceilf( v ); }
    236 long double ceil( long double v ) { return ceill( v ); }
     223float abs( float x ) { return fabsf( x ); }
     224double abs( double x ) { return fabs( x ); }
     225long double abs( long double x ) { return fabsl( x ); }
     226float abs( float _Complex x ) { return cabsf( x ); }
     227double abs( double _Complex x ) { return cabs( x ); }
     228long double abs( long double _Complex x ) { return cabsl( x ); }
    237229
    238230//---------------------------------------
Note: See TracChangeset for help on using the changeset viewer.