Ignore:
Timestamp:
Mar 3, 2016, 1:28:56 PM (10 years ago)
Author:
Aaron Moss <a3moss@…>
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:
3627356
Parents:
9d7b3ea (diff), 4040425 (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:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/stdlib.c

    r9d7b3ea r36ebd03  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 10 15:45:56 2016
    13 // Update Count     : 140
     12// Last Modified On : Wed Mar  2 17:38:47 2016
     13// Update Count     : 143
    1414//
    1515
     
    2727} // extern "C"
    2828
    29 forall( type T ) T * memset( T * ptr, unsigned char fill ) { // use default value '\0' for fill
     29forall( otype T ) T * memset( T * ptr, unsigned char fill ) { // use default value '\0' for fill
    3030        printf( "memset1\n" );
    3131    return (T *)memset( ptr, (int)fill, malloc_usable_size( ptr ) );
    3232} // memset
    33 forall( type T ) T * memset( T * ptr ) {                                // remove when default value available
     33forall( otype T ) T * memset( T * ptr ) {                               // remove when default value available
    3434        printf( "memset2\n" );
    3535    return (T *)memset( ptr, 0, malloc_usable_size( ptr ) );
    3636} // memset
    3737
    38 forall( type T ) T * malloc( void ) {
     38forall( otype T ) T * malloc( void ) {
    3939        printf( "malloc1\n" );
    4040    return (T *)malloc( sizeof(T) );
    4141} // malloc
    42 forall( type T ) T * malloc( size_t size ) {
     42forall( otype T ) T * malloc( size_t size ) {
    4343        printf( "malloc2\n" );
    4444    return (T *)(void *)malloc( size );
    4545} // malloc
    46 forall( type T ) T * malloc( char fill ) {
     46forall( otype T ) T * malloc( char fill ) {
    4747        printf( "malloc3\n" );
    4848        T * ptr = (T *)malloc( sizeof(T) );
     
    5050} // malloc
    5151
    52 forall( type T ) T * calloc( size_t size ) {
     52forall( otype T ) T * calloc( size_t size ) {
    5353        printf( "calloc\n" );
    5454    return (T *)calloc( size, sizeof(T) );
    5555} // calloc
    5656
    57 forall( type T ) T * realloc( T * ptr, size_t size ) {
     57forall( otype T ) T * realloc( T * ptr, size_t size ) {
    5858        printf( "realloc1\n" );
    5959    return (T *)(void *)realloc( (void *)ptr, size );
    6060} // realloc
    61 forall( type T ) T * realloc( T * ptr, size_t size, unsigned char fill ) {
     61forall( otype T ) T * realloc( T * ptr, size_t size, unsigned char fill ) {
    6262        printf( "realloc2\n" );
    6363    char * nptr = (T *)(void *)realloc( (void *)ptr, size );
     
    6767} // realloc
    6868
    69 forall( type T ) T * malloc( T * ptr, size_t size ) {
     69forall( otype T ) T * malloc( T * ptr, size_t size ) {
    7070        printf( "malloc4\n" );
    7171    return (T *)realloc( ptr, size );
    7272} // malloc
    73 forall( type T ) T * malloc( T * ptr, size_t size, unsigned char fill ) {
     73forall( otype T ) T * malloc( T * ptr, size_t size, unsigned char fill ) {
    7474        printf( "malloc5\n" );
    7575    return (T *)realloc( ptr, size, fill );
    7676} // malloc
    7777
    78 forall( type T ) T * aligned_alloc( size_t alignment ) {
     78forall( otype T ) T * aligned_alloc( size_t alignment ) {
    7979        printf( "aligned_alloc\n" );
    8080    return (T *)memalign( alignment, sizeof(T) );
    8181} // aligned_alloc
    8282
    83 forall( type T ) T * memalign( size_t alignment ) {
     83forall( otype T ) T * memalign( size_t alignment ) {
    8484        printf( "memalign\n" );
    8585    return (T *)memalign( alignment, sizeof(T) );
    8686} // memalign
    8787
    88 forall( type T ) int posix_memalign( T ** ptr, size_t alignment ) {
     88forall( otype T ) int posix_memalign( T ** ptr, size_t alignment ) {
    8989        printf( "posix_memalign\n" );
    9090    return posix_memalign( (void **)ptr, alignment, sizeof(T) );
     
    123123        return ulli;
    124124}
     125
    125126float ato( const char * ptr ) {
    126127        float f;
     
    138139        return ld;
    139140}
     141
    140142float _Complex ato( const char * ptr ) {
    141143        float re, im;
     
    172174        return strtoull( sptr, eptr, base );
    173175}
     176
    174177float strto( const char * sptr, char ** eptr ) {
    175178        return strtof( sptr, eptr );
     
    181184        return strtold( sptr, eptr );
    182185}
     186
    183187float _Complex strto( const char * sptr, char ** eptr ) {
    184188        float re, im;
     
    208212//---------------------------------------
    209213
    210 forall( type T | { int ?<?( T, T ); } )
     214forall( otype T | { int ?<?( T, T ); } )
    211215T * bsearch( const T key, const T * arr, size_t dimension ) {
    212216        int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
     
    214218} // bsearch
    215219
    216 forall( type T | { int ?<?( T, T ); } )
     220forall( otype T | { int ?<?( T, T ); } )
    217221void qsort( const T * arr, size_t dimension ) {
    218222        int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
     
    222226//---------------------------------------
    223227
    224 forall( type T | { T ?/?( T, T ); T ?%?( T, T ); } )
     228forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } )
    225229[ T, T ] div( T t1, T t2 ) { /* return [ t1 / t2, t1 % t2 ]; */ }
    226230
     
    253257//---------------------------------------
    254258
    255 forall( type T | { int ?<?( T, T ); } )
     259forall( otype T | { int ?<?( T, T ); } )
    256260T min( const T t1, const T t2 ) {
    257261        return t1 < t2 ? t1 : t2;
    258262} // min
    259263
    260 forall( type T | { int ?>?( T, T ); } )
     264forall( otype T | { int ?>?( T, T ); } )
    261265T max( const T t1, const T t2 ) {
    262266        return t1 > t2 ? t1 : t2;
    263267} // max
    264268
    265 forall( type T )
     269forall( otype T )
    266270void swap( T * t1, T * t2 ) {
    267271        T temp = *t1;
Note: See TracChangeset for help on using the changeset viewer.