Ignore:
Timestamp:
Apr 21, 2016, 8:24:07 AM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.