Changeset ca7949b for libcfa/src/stdlib.hfa
- Timestamp:
- Mar 6, 2020, 1:46:00 PM (5 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:
- 6b4a1bf
- Parents:
- 63aea5a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/stdlib.hfa
r63aea5a rca7949b 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 4 08:27:01202013 // Update Count : 40 112 // Last Modified On : Thu Mar 5 11:29:06 2020 13 // Update Count : 407 14 14 // 15 15 … … 21 21 #include <stdlib.h> // *alloc, strto*, ato* 22 22 23 // Reduce includes by explicitly defining these routines. 23 24 extern "C" { 24 25 void * memalign( size_t align, size_t size ); // malloc.h 26 void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ); // CFA heap 25 27 void * memset( void * dest, int fill, size_t size ); // string.h 26 28 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 heap28 29 } // extern "C" 29 30 … … 40 41 41 42 static inline forall( dtype T | sized(T) ) { 42 // C dynamic allocation43 // Cforall safe equivalents, i.e., implicit size specification 43 44 44 45 T * malloc( void ) { … … 72 73 } // posix_memalign 73 74 74 // Cforall dynamic allocation75 // Cforall safe general allocation, fill, resize, array 75 76 76 77 T * alloc( void ) { … … 159 160 160 161 static inline forall( dtype T | sized(T) ) { 161 // data, non-array types162 // Cforall safe initialization/copy, i.e., implicit size specification, non-array types 162 163 T * memset( T * dest, char fill ) { 163 164 return (T *)memset( dest, fill, sizeof(T) ); … … 170 171 171 172 static inline forall( dtype T | sized(T) ) { 172 // data, array types173 // Cforall safe initialization/copy, i.e., implicit size specification, array types 173 174 T * amemset( T dest[], char fill, size_t dim ) { 174 175 return (T *)(void *)memset( dest, fill, dim * sizeof(T) ); // C memset … … 180 181 } // distribution 181 182 182 // allocation/deallocation and constructor/destructor, non-array types183 // Cforall allocation/deallocation and constructor/destructor, non-array types 183 184 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) T * new( Params p ); 184 185 forall( dtype T | sized(T) | { void ^?{}( T & ); } ) void delete( T * ptr ); 185 186 forall( dtype T, ttype Params | sized(T) | { void ^?{}( T & ); void delete( Params ); } ) void delete( T * ptr, Params rest ); 186 187 187 // allocation/deallocation and constructor/destructor, array types188 // Cforall allocation/deallocation and constructor/destructor, array types 188 189 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) T * anew( size_t dim, Params p ); 189 190 forall( dtype T | sized(T) | { void ^?{}( T & ); } ) void adelete( size_t dim, T arr[] );
Note: See TracChangeset
for help on using the changeset viewer.