Changeset 5bc81e9 for libcfa/src
- Timestamp:
- Apr 23, 2024, 2:28:45 PM (18 months ago)
- Branches:
- master
- Children:
- 566cc33, bab42de
- Parents:
- 58e2ce34 (diff), 4a3eb1c (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:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/fwd.hfa
r58e2ce34 r5bc81e9 374 374 // since if that is the case, the oneshot was fulfilled (unparking this thread) 375 375 // and the oneshot should not be needed any more 376 __attribute__((unused)) struct oneshot * was = this.ptr;376 struct oneshot * was __attribute__((unused)) = this.ptr; // used in option verify 377 377 /* paranoid */ verifyf( was == future_FULFILLED, "Expected this.ptr to be 1p, was %p\n", was ); 378 378 -
libcfa/src/device/cpu.cfa
r58e2ce34 r5bc81e9 239 239 // Returns a 2D array of instances of size [cpu count][cache levels] 240 240 // where cache level doesn't include instruction caches 241 raw_cache_instance ** build_raw_cache_table(unsigned cpus_c, idx_range_t cpus, unsigned idxs, unsigned cache_levels) 242 { 241 raw_cache_instance ** build_raw_cache_table(unsigned cpus_c, idx_range_t cpus, unsigned idxs, unsigned cache_levels) { 243 242 raw_cache_instance ** raw = alloc(cpus_c, '\0'`fill); 244 243 -
libcfa/src/iostream.hfa
r58e2ce34 r5bc81e9 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 6 18:35:54202413 // Update Count : 74 312 // Last Modified On : Sun Apr 21 07:32:19 2024 13 // Update Count : 744 14 14 // 15 15 … … 160 160 161 161 // tuples 162 forall( ostype &, T, Params... | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params); } ) {163 ostype & ?|?( ostype & os, T arg, Paramsrest );164 void ?|?( ostype & os, T arg, Paramsrest );162 forall( ostype &, T, List ... | writeable( T, ostype ) | { ostype & ?|?( ostype &, List ); } ) { 163 ostype & ?|?( ostype & os, T arg, List rest ); 164 void ?|?( ostype & os, T arg, List rest ); 165 165 } // distribution 166 166 -
libcfa/src/stdlib.cfa
r58e2ce34 r5bc81e9 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Mar 17 08:25:32 202413 // Update Count : 69912 // Last Modified On : Sun Apr 21 16:17:22 2024 13 // Update Count : 700 14 14 // 15 15 … … 31 31 // Cforall allocation/deallocation and constructor/destructor, array types 32 32 33 forall( T & | sized(T), TT... | { void ?{}( T &, TT); } )34 T * anew( size_t dim, TTp ) {33 forall( T & | sized(T), Parms ... | { void ?{}( T &, Parms ); } ) 34 T * anew( size_t dim, Parms p ) { 35 35 T * arr = alloc( dim ); 36 36 for ( i; dim ) { … … 51 51 } // adelete 52 52 53 forall( T & | sized(T) | { void ^?{}( T & ); }, TT... | { void adelete( TT); } )54 void adelete( T arr[], TTrest ) {53 forall( T & | sized(T) | { void ^?{}( T & ); }, List ... | { void adelete( List ); } ) 54 void adelete( T arr[], List rest ) { 55 55 if ( arr ) { // ignore null 56 56 size_t dim = malloc_size( arr ) / sizeof( T ); -
libcfa/src/stdlib.hfa
r58e2ce34 r5bc81e9 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 19 09:47:55202413 // Update Count : 82612 // Last Modified On : Tue Apr 23 14:05:21 2024 13 // Update Count : 963 14 14 // 15 15 … … 121 121 122 122 /* 123 FIX ME : fix alloc interface after Ticker Number 214 is resolved, define and add union to S_fill. Then, modify postfix-fill functions to support T * with nmemb, char, and T object of any size. Finally, change alloc_internal. 123 FIX ME : fix alloc interface after Ticker Number 214 is resolved, define and add union to S_fill. Then, modify 124 postfix-fill functions to support T * with nmemb, char, and T object of any size. Finally, change alloc_internal. 124 125 Or, just follow the instructions below for that. 125 126 … … 165 166 */ 166 167 167 typedef struct S_align { inline size_t; } T_align; 168 typedef struct S_resize { inline void *; } T_resize; 169 170 forall( T & ) { 171 struct S_fill { char tag; char c; size_t size; T * at; char t[50]; }; 172 struct S_realloc { inline T *; }; 168 #pragma GCC diagnostic push 169 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 170 #pragma GCC diagnostic ignored "-Wuninitialized" 171 172 struct T_align { size_t align; }; 173 struct T_resize { void * addr; }; 174 struct T_realloc { void * addr; }; 175 forall( T & ) struct T_fill { 176 // 'N' => no fill, 'c' => fill with character c, 'a' => fill first N array elements from another array, 177 // 'A' => fill all array elements from another array, 'T' => fill using a T value. 178 char tag; 179 size_t nelem; // number of elements copied from "at" (used with tag 'a') 180 // union { 181 char c; 182 T * at; 183 char t[64]; // T t; 184 // }; 185 }; 186 187 #pragma GCC diagnostic pop 188 189 static inline { 190 T_align ?`align( size_t a ) { return (T_align){ a }; } 191 T_resize ?`resize( void * a ) { return (T_resize){ a }; } 192 T_realloc ?`realloc( void * a ) { return (T_realloc){ a }; } 173 193 } 174 194 175 static inline T_align ?`align( size_t a ) { return (T_align){a}; }176 static inline T_resize ?`resize( void * a ) { return (T_resize){a}; }177 178 195 static inline forall( T & | sized(T) ) { 179 S_fill(T) ?`fill( T t ) { 180 S_fill(T) ret = { 't' }; 196 T_fill(T) ?`fill( char c ) { return (T_fill(T)){ 'c', 0, c }; } 197 T_fill(T) ?`fill( T t ) { 198 T_fill(T) ret = { 'T' }; 181 199 size_t size = sizeof(T); 182 200 if ( size > sizeof(ret.t) ) { … … 186 204 return ret; 187 205 } 188 S_fill(T) ?`fill( zero_t ) = void; // FIX ME: remove this once ticket 214 is resolved 189 S_fill(T) ?`fill( T * a ) { return (S_fill(T)){ 'T', '0', 0, a }; } // FIX ME: remove this once ticket 214 is resolved 190 S_fill(T) ?`fill( char c ) { return (S_fill(T)){ 'c', c }; } 191 S_fill(T) ?`fill( T a[], size_t nmemb ) { return (S_fill(T)){ 'a', '0', nmemb * sizeof(T), a }; } 192 193 S_realloc(T) ?`realloc ( T * a ) { return (S_realloc(T)){a}; } 194 195 T * alloc_internal$( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T) Fill ) { 196 T * ptr = NULL; 197 size_t size = sizeof(T); 206 T_fill(T) ?`fill( T a[] ) { return (T_fill(T)){ 'A', 0, '\0', a }; } // FIX ME: remove this once ticket 214 is resolved 207 T_fill(T) ?`fill( T a[], size_t nelem ) { return (T_fill(T)){ 'a', nelem * sizeof(T), '\0', a }; } 208 209 // private interface 210 T * alloc_internal$( size_t Dim, T_resize Resize, T_realloc Realloc, size_t Align, T_fill(T) Fill ) { 211 T * ptr; 212 size_t tsize = sizeof(T); 198 213 size_t copy_end = 0; 199 214 200 if ( Resize ) {201 ptr = (T *)(void *)resize( (void *)Resize, Align, Dim *size );202 } else if ( Realloc ) {203 if ( Fill.tag != ' 0' ) copy_end = min(malloc_size( Realloc ), Dim *size );204 ptr = (T *)(void *)realloc( (void *)Realloc, Align, Dim *size );215 if ( Resize.addr ) { 216 ptr = (T *)(void *)resize( Resize.addr, Align, Dim * tsize ); 217 } else if ( Realloc.addr ) { 218 if ( Fill.tag != 'N' ) copy_end = min(malloc_size( Realloc.addr ), Dim * tsize ); 219 ptr = (T *)(void *)realloc( Realloc.addr, Align, Dim * tsize ); 205 220 } else { 206 ptr = (T *)(void *) memalign( Align, Dim *size );207 } 221 ptr = (T *)(void *)memalign( Align, Dim * tsize ); 222 } // if 208 223 209 224 if ( Fill.tag == 'c' ) { 210 memset( (char *)ptr + copy_end, (int)Fill.c, Dim * size - copy_end ); 211 } else if ( Fill.tag == 't' ) { 212 for ( i; copy_end ~ Dim * size ~ size ) { 213 #pragma GCC diagnostic push 214 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 215 assert( size <= sizeof(Fill.t) ); 216 memcpy( (char *)ptr + i, &Fill.t, size ); 217 #pragma GCC diagnostic pop 218 } 225 memset( (char *)ptr + copy_end, (int)Fill.c, Dim * tsize - copy_end ); 226 } else if ( Fill.tag == 'T' ) { 227 for ( i; copy_end ~ Dim * tsize ~ tsize ) { 228 assert( tsize <= sizeof(Fill.t) ); 229 memcpy( (char *)ptr + i, &Fill.t, tsize ); 230 } // for 219 231 } else if ( Fill.tag == 'a' ) { 220 memcpy( (char *)ptr + copy_end, Fill.at, min(Dim * size - copy_end, Fill.size) ); 221 } else if ( Fill.tag == 'T' ) { 222 memcpy( (char *)ptr + copy_end, Fill.at, Dim * size ); 223 } 224 232 memcpy( (char *)ptr + copy_end, Fill.at, min( Dim * tsize - copy_end, Fill.nelem ) ); 233 } else if ( Fill.tag == 'A' ) { 234 memcpy( (char *)ptr + copy_end, Fill.at, Dim * tsize ); 235 } // if 225 236 return ptr; 226 237 } // alloc_internal$ 227 238 228 forall( List ... | { T * alloc_internal$( void *, T *, size_t, size_t, S_fill(T), List ); } ) { 229 T * alloc_internal$( void *, T *, size_t Align, size_t Dim, S_fill(T) Fill, T_resize Resize, List rest ) { 230 return alloc_internal$( Resize, (T*)0p, Align, Dim, Fill, rest); 239 // Dim is a fixed (optional first) parameter, and hence is not set using a postfix function. A dummy parameter is 240 // being overwritten by the postfix argument in the ttype. 241 forall( List ... | { T * alloc_internal$( size_t Dim, T_resize Resize, T_realloc Realloc, size_t Align, T_fill(T) Fill, List ); } ) { 242 // middle interface 243 T * alloc_internal$( size_t Dim, T_resize dummy, T_realloc Realloc, size_t Align, T_fill(T) Fill, T_resize Resize, List rest ) { 244 return alloc_internal$( Dim, Resize, (T_realloc){0p}, Align, Fill, rest ); 231 245 } 232 233 T * alloc_internal$( void *, T *, size_t Align, size_t Dim, S_fill(T) Fill, S_realloc(T) Realloc, List rest ) { 234 return alloc_internal$( (void*)0p, Realloc, Align, Dim, Fill, rest); 246 T * alloc_internal$( size_t Dim, T_resize Resize, T_realloc dummy, size_t Align, T_fill(T) Fill, T_realloc Realloc, List rest ) { 247 return alloc_internal$( Dim, (T_resize){0p}, Realloc, Align, Fill, rest ); 235 248 } 236 237 T * alloc_internal$( void * Resize, T * Realloc, size_t, size_t Dim, S_fill(T) Fill, T_align Align, List rest ) { 238 return alloc_internal$( Resize, Realloc, Align, Dim, Fill, rest); 249 T * alloc_internal$( size_t Dim, T_resize Resize, T_realloc Realloc, size_t dummy, T_fill(T) Fill, T_align Align, List rest ) { 250 return alloc_internal$( Dim, Resize, Realloc, Align.align, Fill, rest ); 239 251 } 240 241 T * alloc_internal$( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T), S_fill(T) Fill, List rest ) { 242 return alloc_internal$( Resize, Realloc, Align, Dim, Fill, rest ); 252 T * alloc_internal$( size_t Dim, T_resize Resize, T_realloc Realloc, size_t Align, T_fill(T) dummy, T_fill(T) Fill, List rest ) { 253 return alloc_internal$( Dim, Resize, Realloc, Align, Fill, rest ); 243 254 } 244 245 T * alloc( List all) {246 return alloc_internal$( ( void*)0p, (T*)0p, (_Alignof(T) > libAlign() ? _Alignof(T) : libAlign()), (size_t)1, (S_fill(T)){'0'}, all);255 // public interface 256 T * alloc( List rest ) { 257 return alloc_internal$( (size_t)1, (T_resize){0p}, (T_realloc){0p}, (_Alignof(T) > libAlign() ? _Alignof(T) : libAlign()), (T_fill(T)){'N'}, rest ); 247 258 } 248 249 T * alloc( size_t dim, List all ) { 250 return alloc_internal$( (void*)0p, (T*)0p, (_Alignof(T) > libAlign() ? _Alignof(T) : libAlign()), dim, (S_fill(T)){'0'}, all ); 259 T * alloc( size_t Dim, List rest ) { 260 return alloc_internal$( Dim, (T_resize){0p}, (T_realloc){0p}, (_Alignof(T) > libAlign() ? _Alignof(T) : libAlign()), (T_fill(T)){'N'}, rest ); 251 261 } 252 262 } // distribution List … … 255 265 static inline forall( T & | sized(T) ) { 256 266 // CFA safe initialization/copy, i.e., implicit size specification, non-array types 257 T * memset( T * dest, char fill ) { 258 return (T *)memset( dest, fill, sizeof(T) ); 267 T * memset( T * dest, char fill ) { // all combinations of pointer/reference 268 return (T *)memset( dest, fill, sizeof(T) ); // C memset 259 269 } // memset 260 261 T * memcpy( T * dest, const T * src ) { 262 return (T *)memcpy( dest, src, sizeof(T) ); 270 T * memset( T & dest, char fill ) { 271 return (T *)memset( &dest, fill, sizeof(T) ); // C memset 272 } // memset 273 274 T * memcpy( T * dest, const T * src ) { // all combinations of pointer/reference 275 return (T *)memcpy( dest, src, sizeof(T) ); // C memcpy 276 } // memcpy 277 T * memcpy( T & dest, const T & src ) { 278 return (T *)memcpy( &dest, &src, sizeof(T) ); // C memcpy 279 } // memcpy 280 T * memcpy( T * dest, const T & src ) { 281 return (T *)memcpy( dest, &src, sizeof(T) ); // C memcpy 282 } // memcpy 283 T * memcpy( T & dest, const T * src ) { 284 return (T *)memcpy( &dest, src, sizeof(T) ); // C memcpy 263 285 } // memcpy 264 286
Note:
See TracChangeset
for help on using the changeset viewer.