Changeset 4a3eb1c
- Timestamp:
- Apr 23, 2024, 2:18:29 PM (7 months ago)
- Branches:
- master
- Children:
- 5bc81e9, 89da3a9
- Parents:
- 13de4478
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/stdlib.hfa
r13de4478 r4a3eb1c 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Apr 22 23:23:58202413 // Update Count : 9 5812 // Last Modified On : Tue Apr 23 14:05:21 2024 13 // Update Count : 963 14 14 // 15 15 … … 265 265 static inline forall( T & | sized(T) ) { 266 266 // CFA safe initialization/copy, i.e., implicit size specification, non-array types 267 T * memset( T * dest, char fill ) { 268 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 269 269 } // memset 270 271 T * memcpy( T * dest, const T * src ) { 272 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 273 285 } // memcpy 274 286 -
tests/alloc.cfa
r13de4478 r4a3eb1c 10 10 // Created On : Wed Feb 3 07:56:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Oct 14 09:31:39 202213 // Update Count : 49 112 // Last Modified On : Tue Apr 23 14:04:11 2024 13 // Update Count : 492 14 14 // 15 15 … … 240 240 free( stp ); 241 241 242 posix_memalign( &stp, Alignment ); 242 posix_memalign( &stp, Alignment ); // CFA posix_memalign 243 243 *stp = (Struct){ 42, 42.5 }; 244 244 assert( (uintptr_t)stp % Alignment == 0 ); … … 275 275 sout | nl; 276 276 277 stp = alloc( dim, Alignment`align ); 277 stp = alloc( dim, Alignment`align ); // CFA array memalign 278 278 assert( (uintptr_t)stp % Alignment == 0 ); 279 279 for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; } … … 316 316 sout | nl; 317 317 318 memset( &st, fill );// CFA memset, type safe318 memset( st, fill ); // CFA memset, type safe 319 319 sout | "CFA memset" | hex(st.x) | hex(st.y); 320 memcpy( &st1, &st );// CFA memcpy, type safe320 memcpy( st1, st ); // CFA memcpy, type safe 321 321 sout | "CFA memcpy" | hex(st1.x) | hex(st1.y); 322 322
Note: See TracChangeset
for help on using the changeset viewer.