Changeset 4e08a54 for libcfa/src
- Timestamp:
- Apr 19, 2024, 12:01:34 PM (8 months ago)
- Branches:
- master
- Children:
- b9b6efb
- Parents:
- da87eaf (diff), 02c80cdc (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:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/string.cfa
rda87eaf r4e08a54 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 7 21:17:06202413 // Update Count : 2 5912 // Last Modified On : Mon Apr 15 21:56:28 2024 13 // Update Count : 260 14 14 // 15 15 … … 198 198 cstr[len] = '\0'; // terminate 199 199 _Ostream_Manip(const char *) cf @= { cstr, f.wd, f.pc, f.base, {f.all} }; 200 os | cf | nonl; 201 return os; 200 return os | cf | nonl; 202 201 } // ?|? 203 202 -
libcfa/src/collections/string_res.cfa
rda87eaf r4e08a54 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 10 17:47:22202413 // Update Count : 8 312 // Last Modified On : Mon Apr 15 21:56:27 2024 13 // Update Count : 85 14 14 // 15 15 … … 200 200 ofstream & ?|?(ofstream & out, const string_res & s) { 201 201 // CFA string is NOT null terminated, so print exactly lnth characters in a minimum width of 0. 202 out | wd( 0, s.Handle.lnth, s.Handle.s ) | nonl; 203 return out; 202 return out | wd( 0, s.Handle.lnth, s.Handle.s ) | nonl; 204 203 } 205 204 -
libcfa/src/stdlib.hfa
rda87eaf r4e08a54 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 1 2 07:39:15 202413 // Update Count : 8 1212 // Last Modified On : Fri Apr 19 09:47:55 2024 13 // Update Count : 826 14 14 // 15 15 … … 47 47 48 48 static inline forall( T & | sized(T) ) { 49 // CFA safe equivalents, i.e., implicit size specification 49 // CFA safe equivalents, i.e., implicit size specification, eliminate return-type cast 50 50 51 51 T * malloc( void ) { … … 64 64 } // calloc 65 65 66 T * resize( T * ptr, size_t size ) { // CFA resize, eliminate return-type cast67 if ( _Alignof(T) <= libAlign() ) return (T *)resize( (void *)ptr, size ); // C FAresize66 T * resize( T * ptr, size_t size ) { 67 if ( _Alignof(T) <= libAlign() ) return (T *)resize( (void *)ptr, size ); // C resize 68 68 else return (T *)resize( (void *)ptr, _Alignof(T), size ); // CFA resize 69 69 } // resize 70 70 71 T * realloc( T * ptr, size_t size ) { // CFA realloc, eliminate return-type cast 71 T * resize( T * ptr, size_t alignment, size_t size ) { 72 return (T *)resize( (void *)ptr, alignment, size ); // CFA resize 73 } // resize 74 75 T * realloc( T * ptr, size_t size ) { // CFA realloc 72 76 if ( _Alignof(T) <= libAlign() ) return (T *)realloc( (void *)ptr, size ); // C realloc 73 77 else return (T *)realloc( (void *)ptr, _Alignof(T), size ); // CFA realloc 74 78 } // realloc 75 79 80 T * realloc( T * ptr, size_t alignment, size_t size ) { 81 return (T *)realloc( (void *)ptr, alignment, size ); // CFA realloc 82 } // realloc 83 84 T * reallocarray( T * ptr, size_t dim ) { // CFA reallocarray 85 if ( _Alignof(T) <= libAlign() ) return (T *)reallocarray( (void *)ptr, dim, sizeof(T) ); // C reallocarray 86 else return (T *)reallocarray( (void *)ptr, _Alignof(T), dim ); // CFA reallocarray 87 } // realloc 88 89 T * reallocarray( T * ptr, size_t alignment, size_t dim ) { 90 return (T *)reallocarray( (void *)ptr, alignment, dim ); // CFA reallocarray 91 } // realloc 92 76 93 T * memalign( size_t align ) { 77 94 return (T *)memalign( align, sizeof(T) ); // C memalign … … 82 99 } // amemalign 83 100 84 T * cmemalign( size_t align, size_t dim 101 T * cmemalign( size_t align, size_t dim ) { 85 102 return (T *)cmemalign( align, dim, sizeof(T) ); // CFA cmemalign 86 103 } // cmemalign … … 159 176 static inline T_resize ?`resize( void * a ) { return (T_resize){a}; } 160 177 161 extern "C" ssize_t write(int fd, const void *buf, size_t count);162 178 static inline forall( T & | sized(T) ) { 163 S_fill(T) ?`fill 179 S_fill(T) ?`fill( T t ) { 164 180 S_fill(T) ret = { 't' }; 165 181 size_t size = sizeof(T); … … 170 186 return ret; 171 187 } 172 S_fill(T) ?`fill 173 S_fill(T) ?`fill 174 S_fill(T) ?`fill 175 S_fill(T) ?`fill 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 }; } 176 192 177 193 S_realloc(T) ?`realloc ( T * a ) { return (S_realloc(T)){a}; } … … 210 226 } // alloc_internal$ 211 227 212 forall( TT... | { T * alloc_internal$( void *, T *, size_t, size_t, S_fill(T), TT); } ) {213 T * alloc_internal$( void *, T *, size_t Align, size_t Dim, S_fill(T) Fill, T_resize Resize, TTrest ) {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 ) { 214 230 return alloc_internal$( Resize, (T*)0p, Align, Dim, Fill, rest); 215 231 } 216 232 217 T * alloc_internal$( void *, T *, size_t Align, size_t Dim, S_fill(T) Fill, S_realloc(T) Realloc, TTrest ) {233 T * alloc_internal$( void *, T *, size_t Align, size_t Dim, S_fill(T) Fill, S_realloc(T) Realloc, List rest ) { 218 234 return alloc_internal$( (void*)0p, Realloc, Align, Dim, Fill, rest); 219 235 } 220 236 221 T * alloc_internal$( void * Resize, T * Realloc, size_t, size_t Dim, S_fill(T) Fill, T_align Align, TTrest ) {237 T * alloc_internal$( void * Resize, T * Realloc, size_t, size_t Dim, S_fill(T) Fill, T_align Align, List rest ) { 222 238 return alloc_internal$( Resize, Realloc, Align, Dim, Fill, rest); 223 239 } 224 240 225 T * alloc_internal$( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T), S_fill(T) Fill, TTrest ) {241 T * alloc_internal$( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T), S_fill(T) Fill, List rest ) { 226 242 return alloc_internal$( Resize, Realloc, Align, Dim, Fill, rest ); 227 243 } 228 244 229 T * alloc( TTall ) {245 T * alloc( List all ) { 230 246 return alloc_internal$( (void*)0p, (T*)0p, (_Alignof(T) > libAlign() ? _Alignof(T) : libAlign()), (size_t)1, (S_fill(T)){'0'}, all ); 231 247 } 232 248 233 T * alloc( size_t dim, TTall ) {249 T * alloc( size_t dim, List all ) { 234 250 return alloc_internal$( (void*)0p, (T*)0p, (_Alignof(T) > libAlign() ? _Alignof(T) : libAlign()), dim, (S_fill(T)){'0'}, all ); 235 251 } 236 } // distribution TT252 } // distribution List 237 253 } // distribution T 238 254 … … 258 274 259 275 // CFA deallocation for multiple objects 260 static inline forall( T & ) // FIX ME, problems with 0p in list276 static inline forall( T & ) 261 277 void free( T * ptr ) { 262 278 free( (void *)ptr ); // C free 263 279 } // free 264 static inline forall( T &, TT... | { void free( TT); } )265 void free( T * ptr, TTrest ) {280 static inline forall( T &, List ... | { void free( List ); } ) 281 void free( T * ptr, List rest ) { 266 282 free( ptr ); 267 283 free( rest ); … … 269 285 270 286 // CFA allocation/deallocation and constructor/destructor, non-array types 271 static inline forall( T & | sized(T), TT... | { void ?{}( T &, TT); } )272 T * new( TTp ) {287 static inline forall( T & | sized(T), Parms ... | { void ?{}( T &, Parms ); } ) 288 T * new( Parms p ) { 273 289 return &(*(T *)malloc()){ p }; // run constructor 274 290 } // new … … 282 298 free( ptr ); // always call free 283 299 } // delete 284 static inline forall( T &, TT... | { void ^?{}( T & ); void delete( TT); } )285 void delete( T * ptr, TTrest ) {300 static inline forall( T &, List ... | { void ^?{}( T & ); void delete( List ); } ) 301 void delete( T * ptr, List rest ) { 286 302 delete( ptr ); 287 303 delete( rest ); … … 289 305 290 306 // CFA allocation/deallocation and constructor/destructor, array types 291 forall( T & | sized(T), TT... | { void ?{}( T &, TT ); } ) T * anew( size_t dim, TTp );307 forall( T & | sized(T), Parms ... | { void ?{}( T &, Parms ); } ) T * anew( size_t dim, Parms p ); 292 308 forall( T & | sized(T) | { void ^?{}( T & ); } ) void adelete( T arr[] ); 293 forall( T & | sized(T) | { void ^?{}( T & ); }, TT... | { void adelete( TT ); } ) void adelete( T arr[], TT rest ); 309 forall( T & | sized(T) | { void ^?{}( T & ); }, List ... | { void adelete( List ); } ) void adelete( T arr[], List rest ); 310 294 311 //--------------------------------------- 295 312 -
libcfa/src/time.hfa
rda87eaf r4e08a54 10 10 // Created On : Wed Mar 14 23:18:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Oct 8 09:07:48 202213 // Update Count : 6 6812 // Last Modified On : Thu Apr 18 12:07:21 2024 13 // Update Count : 670 14 14 // 15 15 … … 84 84 Duration ?`m( int64_t min ) { return (Duration)@{ min * (60LL * TIMEGRAN) }; } 85 85 Duration ?`m( double min ) { return (Duration)@{ min * (60LL * TIMEGRAN) }; } 86 Duration ?`h( int64_t hour s ) { return (Duration)@{ hours* (60LL * 60LL * TIMEGRAN) }; }87 Duration ?`h( double hour s ) { return (Duration)@{ hours* (60LL * 60LL * TIMEGRAN) }; }88 Duration ?`d( int64_t day s ) { return (Duration)@{ days* (24LL * 60LL * 60LL * TIMEGRAN) }; }89 Duration ?`d( double day s ) { return (Duration)@{ days* (24LL * 60LL * 60LL * TIMEGRAN) }; }90 Duration ?`w( int64_t week s ) { return (Duration)@{ weeks* (7LL * 24LL * 60LL * 60LL * TIMEGRAN) }; }91 Duration ?`w( double week s ) { return (Duration)@{ weeks* (7LL * 24LL * 60LL * 60LL * TIMEGRAN) }; }86 Duration ?`h( int64_t hour ) { return (Duration)@{ hour * (60LL * 60LL * TIMEGRAN) }; } 87 Duration ?`h( double hour ) { return (Duration)@{ hour * (60LL * 60LL * TIMEGRAN) }; } 88 Duration ?`d( int64_t day ) { return (Duration)@{ day * (24LL * 60LL * 60LL * TIMEGRAN) }; } 89 Duration ?`d( double day ) { return (Duration)@{ day * (24LL * 60LL * 60LL * TIMEGRAN) }; } 90 Duration ?`w( int64_t week ) { return (Duration)@{ week * (7LL * 24LL * 60LL * 60LL * TIMEGRAN) }; } 91 Duration ?`w( double week ) { return (Duration)@{ week * (7LL * 24LL * 60LL * 60LL * TIMEGRAN) }; } 92 92 93 93 int64_t ?`ns( Duration dur ) { return dur.tn; }
Note: See TracChangeset
for help on using the changeset viewer.