Changeset 73d0c54a for libcfa/src/stdlib.hfa
- Timestamp:
- Apr 21, 2021, 3:39:14 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b39e6566
- Parents:
- 665edf40 (diff), 7711064 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/stdlib.hfa
r665edf40 r73d0c54a 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Jan 21 22:02:13 202113 // Update Count : 57 412 // Last Modified On : Tue Apr 20 21:20:03 2021 13 // Update Count : 575 14 14 // 15 15 … … 44 44 45 45 // Macro because of returns 46 #define $ARRAY_ALLOC( allocation, alignment, dim ) \46 #define ARRAY_ALLOC$( allocation, alignment, dim ) \ 47 47 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)allocation( dim, (size_t)sizeof(T) ); /* C allocation */ \ 48 48 else return (T *)alignment( _Alignof(T), dim, sizeof(T) ) … … 57 57 58 58 T * aalloc( size_t dim ) { 59 $ARRAY_ALLOC( aalloc, amemalign, dim );59 ARRAY_ALLOC$( aalloc, amemalign, dim ); 60 60 } // aalloc 61 61 62 62 T * calloc( size_t dim ) { 63 $ARRAY_ALLOC( calloc, cmemalign, dim );63 ARRAY_ALLOC$( calloc, cmemalign, dim ); 64 64 } // calloc 65 65 … … 119 119 S_fill(T) ?`fill( T a[], size_t nmemb ) { S_fill(T) ret = {'a', nmemb}; ret.fill.a = a; return ret; } 120 120 121 3. Replace the $alloc_internalfunction which is outside ttype forall-block with following function:122 T * $alloc_internal( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T) Fill) {121 3. Replace the alloc_internal$ function which is outside ttype forall-block with following function: 122 T * alloc_internal$( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T) Fill) { 123 123 T * ptr = NULL; 124 124 size_t size = sizeof(T); … … 145 145 146 146 return ptr; 147 } // $alloc_internal147 } // alloc_internal$ 148 148 */ 149 149 … … 175 175 S_realloc(T) ?`realloc ( T * a ) { return (S_realloc(T)){a}; } 176 176 177 T * $alloc_internal( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T) Fill ) {177 T * alloc_internal$( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T) Fill ) { 178 178 T * ptr = NULL; 179 179 size_t size = sizeof(T); … … 206 206 207 207 return ptr; 208 } // $alloc_internal209 210 forall( TT... | { T * $alloc_internal( void *, T *, size_t, size_t, S_fill(T), TT ); } ) {211 212 T * $alloc_internal( void * , T * Realloc, size_t Align, size_t Dim, S_fill(T) Fill, T_resize Resize, TT rest) {213 return $alloc_internal( Resize, (T*)0p, Align, Dim, Fill, rest);214 } 215 216 T * $alloc_internal( void * Resize, T * , size_t Align, size_t Dim, S_fill(T) Fill, S_realloc(T) Realloc, TT rest) {217 return $alloc_internal( (void*)0p, Realloc, Align, Dim, Fill, rest);218 } 219 220 T * $alloc_internal( void * Resize, T * Realloc, size_t , size_t Dim, S_fill(T) Fill, T_align Align, TT rest) {221 return $alloc_internal( Resize, Realloc, Align, Dim, Fill, rest);222 } 223 224 T * $alloc_internal( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T) , S_fill(T) Fill, TT rest) {225 return $alloc_internal( Resize, Realloc, Align, Dim, Fill, rest);208 } // alloc_internal$ 209 210 forall( TT... | { T * alloc_internal$( void *, T *, size_t, size_t, S_fill(T), TT ); } ) { 211 212 T * alloc_internal$( void * , T * Realloc, size_t Align, size_t Dim, S_fill(T) Fill, T_resize Resize, TT rest) { 213 return alloc_internal$( Resize, (T*)0p, Align, Dim, Fill, rest); 214 } 215 216 T * alloc_internal$( void * Resize, T * , size_t Align, size_t Dim, S_fill(T) Fill, S_realloc(T) Realloc, TT rest) { 217 return alloc_internal$( (void*)0p, Realloc, Align, Dim, Fill, rest); 218 } 219 220 T * alloc_internal$( void * Resize, T * Realloc, size_t , size_t Dim, S_fill(T) Fill, T_align Align, TT rest) { 221 return alloc_internal$( Resize, Realloc, Align, Dim, Fill, rest); 222 } 223 224 T * alloc_internal$( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T) , S_fill(T) Fill, TT rest) { 225 return alloc_internal$( Resize, Realloc, Align, Dim, Fill, rest); 226 226 } 227 227 228 228 T * alloc( TT all ) { 229 return $alloc_internal( (void*)0p, (T*)0p, (_Alignof(T) > libAlign() ? _Alignof(T) : libAlign()), (size_t)1, (S_fill(T)){'0'}, all);229 return alloc_internal$( (void*)0p, (T*)0p, (_Alignof(T) > libAlign() ? _Alignof(T) : libAlign()), (size_t)1, (S_fill(T)){'0'}, all); 230 230 } 231 231 232 232 T * alloc( size_t dim, TT all ) { 233 return $alloc_internal( (void*)0p, (T*)0p, (_Alignof(T) > libAlign() ? _Alignof(T) : libAlign()), dim, (S_fill(T)){'0'}, all);233 return alloc_internal$( (void*)0p, (T*)0p, (_Alignof(T) > libAlign() ? _Alignof(T) : libAlign()), dim, (S_fill(T)){'0'}, all); 234 234 } 235 235
Note: See TracChangeset
for help on using the changeset viewer.