- Timestamp:
- Dec 12, 2020, 2:04:53 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- aac5dfd, b4aa1ab
- Parents:
- 2dda05d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/stdlib.hfa
r2dda05d r4803a901 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 8 18:27:22202013 // Update Count : 5 2412 // Last Modified On : Sat Dec 12 13:52:34 2020 13 // Update Count : 536 14 14 // 15 15 … … 49 49 50 50 static inline forall( dtype T | sized(T) ) { 51 // C forallsafe equivalents, i.e., implicit size specification51 // CFA safe equivalents, i.e., implicit size specification 52 52 53 53 T * malloc( void ) { … … 234 234 235 235 static inline forall( dtype T | sized(T) ) { 236 // C forallsafe initialization/copy, i.e., implicit size specification, non-array types236 // CFA safe initialization/copy, i.e., implicit size specification, non-array types 237 237 T * memset( T * dest, char fill ) { 238 238 return (T *)memset( dest, fill, sizeof(T) ); … … 243 243 } // memcpy 244 244 245 // C forallsafe initialization/copy, i.e., implicit size specification, array types245 // CFA safe initialization/copy, i.e., implicit size specification, array types 246 246 T * amemset( T dest[], char fill, size_t dim ) { 247 247 return (T *)(void *)memset( dest, fill, dim * sizeof(T) ); // C memset … … 253 253 } // distribution 254 254 255 // Cforall deallocation for multiple objects 255 // CFA deallocation for multiple objects 256 static inline forall( dtype T ) // FIX ME, problems with 0p in list 257 void free( T * ptr ) { 258 free( (void *)ptr ); // C free 259 } // free 256 260 static inline forall( dtype T, ttype TT | { void free( TT ); } ) 257 void free( T * addr, TT rest ) {258 free( ( void *)addr ); // use C free261 void free( T * ptr, TT rest ) { 262 free( ptr ); 259 263 free( rest ); 260 264 } // free 261 265 262 // C forallallocation/deallocation and constructor/destructor, non-array types266 // CFA allocation/deallocation and constructor/destructor, non-array types 263 267 static inline forall( dtype T | sized(T), ttype TT | { void ?{}( T &, TT ); } ) 264 268 T * new( TT p ) { … … 272 276 ^(*ptr){}; // run destructor 273 277 } // if 274 free( ptr ); 278 free( ptr ); // always call free 275 279 } // delete 276 277 280 static inline forall( dtype T, ttype TT | { void ^?{}( T & ); void delete( TT ); } ) 278 281 void delete( T * ptr, TT rest ) { … … 281 284 } // delete 282 285 283 // C forallallocation/deallocation and constructor/destructor, array types286 // CFA allocation/deallocation and constructor/destructor, array types 284 287 forall( dtype T | sized(T), ttype TT | { void ?{}( T &, TT ); } ) T * anew( size_t dim, TT p ); 285 288 forall( dtype T | sized(T) | { void ^?{}( T & ); } ) void adelete( T arr[] );
Note: See TracChangeset
for help on using the changeset viewer.