Changeset c3a2007 for libcfa/src


Ignore:
Timestamp:
Oct 28, 2019, 4:28:37 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8364209
Parents:
c921712 (diff), 9bdb8b7 (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

Location:
libcfa/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    rc921712 rc3a2007  
    3232# use -no-include-stdhdr to prevent rebuild cycles
    3333# The built sources must not depend on the installed headers
    34 AM_CFAFLAGS = -quiet -cfalib @PRELUDEFLAG@ -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
     34AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    3535AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3636AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
     
    9696
    9797prelude.o : prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@
    98         ${AM_V_GEN}$(CFACOMPILE) -quiet @PRELUDEFLAG@ -XCFA -l ${<} -c -o ${@}
     98        ${AM_V_GEN}$(CFACOMPILE) -quiet -XCFA -l ${<} -c -o ${@}
    9999
    100100prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@
    101101        ${AM_V_GEN}$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile \
    102         $(CFACOMPILE) -quiet @PRELUDEFLAG@ -XCFA -l ${<} -c -o ${@}
     102        $(CFACOMPILE) -quiet -XCFA -l ${<} -c -o ${@}
    103103
    104104#----------------------------------------------------------------------------------------------------------------
  • libcfa/src/Makefile.in

    rc921712 rc3a2007  
    349349PACKAGE_VERSION = @PACKAGE_VERSION@
    350350PATH_SEPARATOR = @PATH_SEPARATOR@
    351 PRELUDEFLAG = @PRELUDEFLAG@
    352351RANLIB = @RANLIB@
    353352SED = @SED@
     
    445444# use -no-include-stdhdr to prevent rebuild cycles
    446445# The built sources must not depend on the installed headers
    447 AM_CFAFLAGS = -quiet -cfalib @PRELUDEFLAG@ -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
     446AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    448447AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
    449448AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
     
    954953
    955954prelude.o : prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@
    956         ${AM_V_GEN}$(CFACOMPILE) -quiet @PRELUDEFLAG@ -XCFA -l ${<} -c -o ${@}
     955        ${AM_V_GEN}$(CFACOMPILE) -quiet -XCFA -l ${<} -c -o ${@}
    957956
    958957prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@
    959958        ${AM_V_GEN}$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile \
    960         $(CFACOMPILE) -quiet @PRELUDEFLAG@ -XCFA -l ${<} -c -o ${@}
     959        $(CFACOMPILE) -quiet -XCFA -l ${<} -c -o ${@}
    961960
    962961#----------------------------------------------------------------------------------------------------------------
  • libcfa/src/concurrency/kernel_private.hfa

    rc921712 rc3a2007  
    3434static inline void WakeThread( thread_desc * thrd ) {
    3535        if( !thrd ) return;
     36
     37        verify(thrd->state == Inactive);
    3638
    3739        disable_interrupts();
  • libcfa/src/heap.cfa

    rc921712 rc3a2007  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 24 13:12:45 2019
    13 // Update Count     : 550
     12// Last Modified On : Fri Oct 18 07:42:09 2019
     13// Update Count     : 556
    1414//
    1515
     
    541541        // along with the block and is a multiple of the alignment size.
    542542
     543  if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0;
    543544        size_t tsize = size + sizeof(HeapManager.Storage);
    544545        if ( likely( tsize < mmapStart ) ) {                            // small size => sbrk
     
    592593                block->header.kind.real.home = freeElem;                // pointer back to free list of apropriate size
    593594        } else {                                                                                        // large size => mmap
     595  if ( unlikely( size > ~0ul - pageSize ) ) return 0;
    594596                tsize = libCeiling( tsize, pageSize );                  // must be multiple of page size
    595597                #ifdef __STATISTICS__
     
    888890        } // realloc
    889891
    890 
    891892        // The obsolete function memalign() allocates size bytes and returns a pointer to the allocated memory. The memory
    892893        // address will be a multiple of alignment, which must be a power of two.
     
    992993        size_t malloc_alignment( void * addr ) {
    993994          if ( unlikely( addr == 0 ) ) return libAlign();       // minimum alignment
    994                 HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) );
     995                HeapManager.Storage.Header * header = headerAddr( addr );
    995996                if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
    996997                        return header->kind.fake.alignment & -2;        // remove flag from value
     
    10041005        bool malloc_zero_fill( void * addr ) {
    10051006          if ( unlikely( addr == 0 ) ) return false;            // null allocation is not zero fill
    1006 
    1007                 HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) );
     1007                HeapManager.Storage.Header * header = headerAddr( addr );
    10081008                if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
    10091009                        header = (HeapManager.Storage.Header *)((char *)header - header->kind.fake.offset);
  • libcfa/src/stdlib.cfa

    rc921712 rc3a2007  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 24 17:34:44 2019
    13 // Update Count     : 462
     12// Last Modified On : Tue Oct 22 08:57:52 2019
     13// Update Count     : 478
    1414//
    1515
     
    2121#include <string.h>                                                                             // memcpy, memset
    2222#include <malloc.h>                                                                             // malloc_usable_size
    23 #include <math.h>                                                                               // fabsf, fabs, fabsl
     23//#include <math.h>                                                                             // fabsf, fabs, fabsl
    2424#include <complex.h>                                                                    // _Complex_I
    2525#include <assert.h>
     
    2727//---------------------------------------
    2828
    29 // resize, non-array types
    30 forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill ) {
    31         size_t olen = malloc_usable_size( ptr );                        // current allocation
    32     char * nptr = (void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc
    33         size_t nlen = malloc_usable_size( nptr );                       // new allocation
    34         if ( nlen > olen ) {                                                            // larger ?
    35                 memset( nptr + olen, (int)fill, nlen - olen );  // initialize added storage
    36         } //
    37     return (T *)nptr;
    38 } // alloc
     29forall( dtype T | sized(T) ) {
     30        T * alloc_set( T ptr[], size_t dim, char fill ) {       // realloc array with fill
     31                size_t olen = malloc_usable_size( ptr );                // current allocation
     32                char * nptr = (char *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
     33                size_t nlen = malloc_usable_size( nptr );               // new allocation
     34                if ( nlen > olen ) {                                                    // larger ?
     35                        memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage
     36                } // if
     37                return (T *)nptr;
     38        } // alloc_set
     39
     40        T * alloc_align( T ptr[], size_t align ) {                      // aligned realloc array
     41                char * nptr;
     42                size_t alignment = malloc_alignment( ptr );
     43                if ( align != alignment && (uintptr_t)ptr % align != 0 ) {
     44                        size_t olen = malloc_usable_size( ptr );        // current allocation
     45                        nptr = (char *)memalign( align, olen );
     46                        size_t nlen = malloc_usable_size( nptr );       // new allocation
     47                        size_t lnth = olen < nlen ? olen : nlen;        // min
     48                        memcpy( nptr, ptr, lnth );                                      // initialize storage
     49                        free( ptr );
     50                } else {
     51                        nptr = (char *)ptr;
     52                } // if
     53                return (T *)nptr;
     54        } // alloc_align
     55
     56        T * alloc_align( T ptr[], size_t align, size_t dim ) { // aligned realloc array
     57                char * nptr;
     58                size_t alignment = malloc_alignment( ptr );
     59                if ( align != alignment ) {
     60                        size_t olen = malloc_usable_size( ptr );        // current allocation
     61                        nptr = (char *)memalign( align, dim * sizeof(T) );
     62                        size_t nlen = malloc_usable_size( nptr );       // new allocation
     63                        size_t lnth = olen < nlen ? olen : nlen;        // min
     64                        memcpy( nptr, ptr, lnth );                                      // initialize storage
     65                        free( ptr );
     66                } else {
     67                        nptr = (char *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
     68                } // if
     69                return (T *)nptr;
     70        } // alloc_align
     71
     72        T * alloc_align_set( T ptr[], size_t align, char fill ) { // aligned realloc with fill
     73                size_t olen = malloc_usable_size( ptr );                // current allocation
     74                char * nptr = alloc_align( ptr, align );
     75                size_t nlen = malloc_usable_size( nptr );               // new allocation
     76                if ( nlen > olen ) {                                                    // larger ?
     77                        memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage
     78                } // if
     79                return (T *)nptr;
     80        } // alloc_align_set
     81} // distribution
    3982
    4083// allocation/deallocation and constructor/destructor, non-array types
    4184forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
    4285T * new( Params p ) {
    43         return &(*malloc()){ p };                                                               // run constructor
     86        return &(*malloc()){ p };                                                       // run constructor
    4487} // new
    4588
     
    4790void delete( T * ptr ) {
    4891        if ( ptr ) {                                                                            // ignore null
    49                 ^(*ptr){};                                                                                      // run destructor
     92                ^(*ptr){};                                                                              // run destructor
    5093                free( ptr );
    5194        } // if
     
    5598void delete( T * ptr, Params rest ) {
    5699        if ( ptr ) {                                                                            // ignore null
    57                 ^(*ptr){};                                                                                      // run destructor
     100                ^(*ptr){};                                                                              // run destructor
    58101                free( ptr );
    59102        } // if
  • libcfa/src/stdlib.hfa

    rc921712 rc3a2007  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 23 14:14:59 2019
    13 // Update Count     : 373
     12// Last Modified On : Sun Oct 20 22:57:33 2019
     13// Update Count     : 390
    1414//
    1515
     
    2525        void * memset( void * dest, int fill, size_t size ); // string.h
    2626        void * memcpy( void * dest, const void * src, size_t size ); // string.h
    27     void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ); // CFA
     27    void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ); // CFA heap
    2828} // extern "C"
    2929
     
    5252        T * realloc( T * ptr, size_t size ) {
    5353                if ( unlikely( ptr == 0 ) ) return malloc();
    54                 return (T *)(void *)realloc( (void *)ptr, size );
     54                return (T *)(void *)realloc( (void *)ptr, size ); // C realloc
    5555        } // realloc
    5656
    5757        T * memalign( size_t align ) {
    58                 return (T *)memalign( align, sizeof(T) );
     58                return (T *)memalign( align, sizeof(T) );               // C memalign
    5959        } // memalign
    6060
    6161        T * aligned_alloc( size_t align ) {
    62                 return (T *)aligned_alloc( align, sizeof(T) );
     62                return (T *)aligned_alloc( align, sizeof(T) );  // C aligned_alloc
    6363        } // aligned_alloc
    6464
     
    6767        } // posix_memalign
    6868
    69 
    7069        // Cforall dynamic allocation
    7170
     
    7473        } // alloc
    7574
    76         T * alloc( char fill ) {
    77                 T * ptr;
    78                 if ( _Alignof(T) <= libAlign() ) ptr = (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc
    79                 else ptr = (T *)memalign( _Alignof(T), sizeof(T) );
    80                 return (T *)memset( ptr, (int)fill, sizeof(T) ); // initialize with fill value
    81         } // alloc
    82 
    8375        T * alloc( size_t dim ) {
    84                 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C malloc
     76                if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( dim * (size_t)sizeof(T) );
    8577                else return (T *)memalign( _Alignof(T), dim * sizeof(T) );
    8678        } // alloc
    8779
    88         T * alloc( size_t dim, char fill ) {
     80        T * alloc( T ptr[], size_t dim ) {                                      // realloc
     81                return realloc( ptr, dim * sizeof(T) );
     82        } // alloc
     83
     84        T * alloc_set( char fill ) {
     85                return (T *)memset( (T *)alloc(), (int)fill, sizeof(T) ); // initialize with fill value
     86        } // alloc
     87
     88        T * alloc_set( T fill ) {
     89                return (T *)memcpy( (T *)alloc(), &fill, sizeof(T) ); // initialize with fill value
     90        } // alloc
     91
     92        T * alloc_set( size_t dim, char fill ) {
    8993                return (T *)memset( (T *)alloc( dim ), (int)fill, dim * sizeof(T) ); // initialize with fill value
    9094        } // alloc
    9195
    92         T * alloc( T ptr[], size_t dim ) {
    93                 return realloc( ptr, dim * sizeof(T) );
    94         } // alloc
    95 } // distribution
    96 
    97 
    98 static inline forall( dtype T | sized(T) ) {
    99         T * align_alloc( size_t align ) {
     96        T * alloc_set( size_t dim, T fill ) {
     97                T * r = (T *)alloc( dim );
     98                for ( i; dim ) { memcpy( &r[i], &fill, sizeof(T) ); } // initialize with fill value
     99                return r;
     100        } // alloc
     101
     102        T * alloc_set( size_t dim, const T fill[] ) {
     103                return (T *)memcpy( (T *)alloc( dim ), fill, dim * sizeof(T) ); // initialize with fill value
     104        } // alloc
     105} // distribution
     106
     107forall( dtype T | sized(T) ) {
     108        T * alloc_set( T ptr[], size_t dim, char fill );        // realloc array with fill
     109} // distribution
     110
     111static inline forall( dtype T | sized(T) ) {
     112        T * alloc_align( size_t align ) {
    100113                return (T *)memalign( align, sizeof(T) );
    101         } // align_alloc
    102 
    103         T * align_alloc( size_t align, char fill ) {
    104                 T * ptr = (T *)memalign( align, sizeof(T) );
    105                 return (T *)memset( ptr, (int)fill, sizeof(T) );
    106         } // align_alloc
    107 
    108         T * align_alloc( size_t align, size_t dim ) {
     114        } // alloc_align
     115
     116        T * alloc_align( size_t align, size_t dim ) {
    109117                return (T *)memalign( align, dim * sizeof(T) );
    110         } // align_alloc
    111 
    112         T * align_alloc( size_t align, size_t dim, char fill ) {
    113                 if ( fill == '\0' ) {
    114                         return (T *)cmemalign( align, dim, sizeof(T) );
    115                 } else {
    116                         return (T *)memset( (T *)memalign( align, dim * sizeof(T) ), (int)fill, dim * sizeof(T) );
    117                 } // if
    118         } // align_alloc
    119 } // distribution
    120 
    121 forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill );
    122 
     118        } // alloc_align
     119
     120        T * alloc_align_set( size_t align, char fill ) {
     121                return (T *)memset( (T *)alloc_align( align ), (int)fill, sizeof(T) ); // initialize with fill value
     122        } // alloc_align
     123
     124        T * alloc_align_set( size_t align, T fill ) {
     125                return (T *)memcpy( (T *)alloc_align( align ), &fill, sizeof(T) ); // initialize with fill value
     126        } // alloc_align
     127
     128        T * alloc_align_set( size_t align, size_t dim, char fill ) {
     129                return (T *)memset( (T *)alloc_align( align, dim ), (int)fill, dim * sizeof(T) ); // initialize with fill value
     130        } // alloc_align
     131
     132        T * alloc_align_set( size_t align, size_t dim, T fill ) {
     133                T * r = (T *)alloc_align( align, dim );
     134                for ( i; dim ) { memcpy( &r[i], &fill, sizeof(T) ); } // initialize with fill value
     135                return r;
     136        } // alloc_align
     137
     138        T * alloc_align_set( size_t align, size_t dim, const T fill[] ) {
     139                return (T *)memcpy( (T *)alloc_align( align, dim ), fill, dim * sizeof(T) );
     140        } // alloc_align
     141} // distribution
     142
     143forall( 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
     146        T * alloc_align_set( T ptr[], size_t align, size_t dim, char fill ); // aligned realloc array with fill
     147} // distribution
    123148
    124149static inline forall( dtype T | sized(T) ) {
    125150        // data, non-array types
    126 
    127151        T * memset( T * dest, char fill ) {
    128152                return (T *)memset( dest, fill, sizeof(T) );
     
    136160static inline forall( dtype T | sized(T) ) {
    137161        // data, array types
    138 
    139162        T * amemset( T dest[], char fill, size_t dim ) {
    140163                return (T *)(void *)memset( dest, fill, dim * sizeof(T) ); // C memset
Note: See TracChangeset for help on using the changeset viewer.