Ignore:
Timestamp:
Dec 12, 2019, 10:04:15 AM (4 years ago)
Author:
Dmitry Kobets <dkobets@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
e752e4e
Parents:
aca6a54c (diff), 2cd949b (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' into vector-generic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/stdlib.hfa

    raca6a54c r2fa5bd2  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 20 22:57:33 2019
    13 // Update Count     : 390
     12// Last Modified On : Fri Nov 29 23:08:02 2019
     13// Update Count     : 400
    1414//
    1515
     
    2828} // extern "C"
    2929
     30void * realloc( void * oaddr, size_t nalign, size_t size ); // CFA heap
     31
    3032//---------------------------------------
    3133
     
    5052        } // calloc
    5153
    52         T * realloc( T * ptr, size_t size ) {
    53                 if ( unlikely( ptr == 0 ) ) return malloc();
     54        T * realloc( T * ptr, size_t size ) {                           // CFA realloc, eliminate return-type cast
    5455                return (T *)(void *)realloc( (void *)ptr, size ); // C realloc
    5556        } // realloc
     
    5960        } // memalign
    6061
     62        T * cmemalign( size_t align, size_t dim  ) {
     63                return (T *)cmemalign( align, dim, sizeof(T) ); // CFA cmemalign
     64        } // cmemalign
     65
    6166        T * aligned_alloc( size_t align ) {
    6267                return (T *)aligned_alloc( align, sizeof(T) );  // C aligned_alloc
     
    7984
    8085        T * alloc( T ptr[], size_t dim ) {                                      // realloc
    81                 return realloc( ptr, dim * sizeof(T) );
     86                return (T *)(void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
    8287        } // alloc
    8388
     
    118123        } // alloc_align
    119124
     125        T * alloc_align( T ptr[], size_t align ) {                      // aligned realloc array
     126                return (T *)(void *)realloc( (void *)ptr, align, sizeof(T) ); // CFA realloc
     127        } // alloc_align
     128
     129        T * alloc_align( T ptr[], size_t align, size_t dim ) { // aligned realloc array
     130                return (T *)(void *)realloc( (void *)ptr, align, dim * sizeof(T) ); // CFA realloc
     131        } // alloc_align
     132
    120133        T * alloc_align_set( size_t align, char fill ) {
    121134                return (T *)memset( (T *)alloc_align( align ), (int)fill, sizeof(T) ); // initialize with fill value
     
    142155
    143156forall( dtype T | sized(T) ) {
    144         T * alloc_align( T ptr[], size_t align );                       // realign
    145         T * alloc_align( T ptr[], size_t align, size_t dim ); // aligned realloc array
    146157        T * alloc_align_set( T ptr[], size_t align, size_t dim, char fill ); // aligned realloc array with fill
    147158} // distribution
     
    199210
    200211static inline {
    201         int ato( const char * sptr ) { return (int)strtol( sptr, 0, 10 ); }
    202         unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0, 10 ); }
    203         long int ato( const char * sptr ) { return strtol( sptr, 0, 10 ); }
    204         unsigned long int ato( const char * sptr ) { return strtoul( sptr, 0, 10 ); }
    205         long long int ato( const char * sptr ) { return strtoll( sptr, 0, 10 ); }
    206         unsigned long long int ato( const char * sptr ) { return strtoull( sptr, 0, 10 ); }
    207 
    208         float ato( const char * sptr ) { return strtof( sptr, 0 ); }
    209         double ato( const char * sptr ) { return strtod( sptr, 0 ); }
    210         long double ato( const char * sptr ) { return strtold( sptr, 0 ); }
    211 
    212         float _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
    213         double _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
    214         long double _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
     212        int ato( const char * sptr ) { return (int)strtol( sptr, 0p, 10 ); }
     213        unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0p, 10 ); }
     214        long int ato( const char * sptr ) { return strtol( sptr, 0p, 10 ); }
     215        unsigned long int ato( const char * sptr ) { return strtoul( sptr, 0p, 10 ); }
     216        long long int ato( const char * sptr ) { return strtoll( sptr, 0p, 10 ); }
     217        unsigned long long int ato( const char * sptr ) { return strtoull( sptr, 0p, 10 ); }
     218
     219        float ato( const char * sptr ) { return strtof( sptr, 0p ); }
     220        double ato( const char * sptr ) { return strtod( sptr, 0p ); }
     221        long double ato( const char * sptr ) { return strtold( sptr, 0p ); }
     222
     223        float _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
     224        double _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
     225        long double _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
    215226} // distribution
    216227
Note: See TracChangeset for help on using the changeset viewer.