Changeset c3a2007 for libcfa/src
- Timestamp:
- Oct 28, 2019, 4:28:37 PM (6 years ago)
- 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. - Location:
- libcfa/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/Makefile.am
rc921712 rc3a2007 32 32 # use -no-include-stdhdr to prevent rebuild cycles 33 33 # 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@34 AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@ 35 35 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@ 36 36 AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@ … … 96 96 97 97 prelude.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 ${@} 99 99 100 100 prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@ 101 101 ${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 ${@} 103 103 104 104 #---------------------------------------------------------------------------------------------------------------- -
libcfa/src/Makefile.in
rc921712 rc3a2007 349 349 PACKAGE_VERSION = @PACKAGE_VERSION@ 350 350 PATH_SEPARATOR = @PATH_SEPARATOR@ 351 PRELUDEFLAG = @PRELUDEFLAG@352 351 RANLIB = @RANLIB@ 353 352 SED = @SED@ … … 445 444 # use -no-include-stdhdr to prevent rebuild cycles 446 445 # 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@446 AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@ 448 447 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@ 449 448 AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@ … … 954 953 955 954 prelude.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 ${@} 957 956 958 957 prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@ 959 958 ${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 ${@} 961 960 962 961 #---------------------------------------------------------------------------------------------------------------- -
libcfa/src/concurrency/kernel_private.hfa
rc921712 rc3a2007 34 34 static inline void WakeThread( thread_desc * thrd ) { 35 35 if( !thrd ) return; 36 37 verify(thrd->state == Inactive); 36 38 37 39 disable_interrupts(); -
libcfa/src/heap.cfa
rc921712 rc3a2007 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 24 13:12:45201913 // Update Count : 55 012 // Last Modified On : Fri Oct 18 07:42:09 2019 13 // Update Count : 556 14 14 // 15 15 … … 541 541 // along with the block and is a multiple of the alignment size. 542 542 543 if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0; 543 544 size_t tsize = size + sizeof(HeapManager.Storage); 544 545 if ( likely( tsize < mmapStart ) ) { // small size => sbrk … … 592 593 block->header.kind.real.home = freeElem; // pointer back to free list of apropriate size 593 594 } else { // large size => mmap 595 if ( unlikely( size > ~0ul - pageSize ) ) return 0; 594 596 tsize = libCeiling( tsize, pageSize ); // must be multiple of page size 595 597 #ifdef __STATISTICS__ … … 888 890 } // realloc 889 891 890 891 892 // The obsolete function memalign() allocates size bytes and returns a pointer to the allocated memory. The memory 892 893 // address will be a multiple of alignment, which must be a power of two. … … 992 993 size_t malloc_alignment( void * addr ) { 993 994 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 ); 995 996 if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ? 996 997 return header->kind.fake.alignment & -2; // remove flag from value … … 1004 1005 bool malloc_zero_fill( void * addr ) { 1005 1006 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 ); 1008 1008 if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ? 1009 1009 header = (HeapManager.Storage.Header *)((char *)header - header->kind.fake.offset); -
libcfa/src/stdlib.cfa
rc921712 rc3a2007 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 24 17:34:44201913 // Update Count : 4 6212 // Last Modified On : Tue Oct 22 08:57:52 2019 13 // Update Count : 478 14 14 // 15 15 … … 21 21 #include <string.h> // memcpy, memset 22 22 #include <malloc.h> // malloc_usable_size 23 #include <math.h> // fabsf, fabs, fabsl23 //#include <math.h> // fabsf, fabs, fabsl 24 24 #include <complex.h> // _Complex_I 25 25 #include <assert.h> … … 27 27 //--------------------------------------- 28 28 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 29 forall( 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 39 82 40 83 // allocation/deallocation and constructor/destructor, non-array types 41 84 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) 42 85 T * new( Params p ) { 43 return &(*malloc()){ p }; 86 return &(*malloc()){ p }; // run constructor 44 87 } // new 45 88 … … 47 90 void delete( T * ptr ) { 48 91 if ( ptr ) { // ignore null 49 ^(*ptr){}; 92 ^(*ptr){}; // run destructor 50 93 free( ptr ); 51 94 } // if … … 55 98 void delete( T * ptr, Params rest ) { 56 99 if ( ptr ) { // ignore null 57 ^(*ptr){}; 100 ^(*ptr){}; // run destructor 58 101 free( ptr ); 59 102 } // if -
libcfa/src/stdlib.hfa
rc921712 rc3a2007 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 23 14:14:59201913 // Update Count : 3 7312 // Last Modified On : Sun Oct 20 22:57:33 2019 13 // Update Count : 390 14 14 // 15 15 … … 25 25 void * memset( void * dest, int fill, size_t size ); // string.h 26 26 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 28 28 } // extern "C" 29 29 … … 52 52 T * realloc( T * ptr, size_t size ) { 53 53 if ( unlikely( ptr == 0 ) ) return malloc(); 54 return (T *)(void *)realloc( (void *)ptr, size ); 54 return (T *)(void *)realloc( (void *)ptr, size ); // C realloc 55 55 } // realloc 56 56 57 57 T * memalign( size_t align ) { 58 return (T *)memalign( align, sizeof(T) ); 58 return (T *)memalign( align, sizeof(T) ); // C memalign 59 59 } // memalign 60 60 61 61 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 63 63 } // aligned_alloc 64 64 … … 67 67 } // posix_memalign 68 68 69 70 69 // Cforall dynamic allocation 71 70 … … 74 73 } // alloc 75 74 76 T * alloc( char fill ) {77 T * ptr;78 if ( _Alignof(T) <= libAlign() ) ptr = (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc79 else ptr = (T *)memalign( _Alignof(T), sizeof(T) );80 return (T *)memset( ptr, (int)fill, sizeof(T) ); // initialize with fill value81 } // alloc82 83 75 T * alloc( size_t dim ) { 84 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( dim * (size_t)sizeof(T) ); // C malloc76 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( dim * (size_t)sizeof(T) ); 85 77 else return (T *)memalign( _Alignof(T), dim * sizeof(T) ); 86 78 } // alloc 87 79 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 ) { 89 93 return (T *)memset( (T *)alloc( dim ), (int)fill, dim * sizeof(T) ); // initialize with fill value 90 94 } // alloc 91 95 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 107 forall( dtype T | sized(T) ) { 108 T * alloc_set( T ptr[], size_t dim, char fill ); // realloc array with fill 109 } // distribution 110 111 static inline forall( dtype T | sized(T) ) { 112 T * alloc_align( size_t align ) { 100 113 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 ) { 109 117 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 143 forall( 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 123 148 124 149 static inline forall( dtype T | sized(T) ) { 125 150 // data, non-array types 126 127 151 T * memset( T * dest, char fill ) { 128 152 return (T *)memset( dest, fill, sizeof(T) ); … … 136 160 static inline forall( dtype T | sized(T) ) { 137 161 // data, array types 138 139 162 T * amemset( T dest[], char fill, size_t dim ) { 140 163 return (T *)(void *)memset( dest, fill, dim * sizeof(T) ); // C memset
Note:
See TracChangeset
for help on using the changeset viewer.