Changes in / [fa35958:ee0bfa9]
- Location:
- libcfa/src
- Files:
-
- 12 edited
-
concurrency/alarm.cfa (modified) (4 diffs)
-
concurrency/coroutine.hfa (modified) (4 diffs)
-
concurrency/invoke.h (modified) (2 diffs)
-
concurrency/kernel.cfa (modified) (6 diffs)
-
concurrency/kernel.hfa (modified) (2 diffs)
-
concurrency/monitor.cfa (modified) (10 diffs)
-
concurrency/monitor.hfa (modified) (3 diffs)
-
concurrency/mutex.cfa (modified) (4 diffs)
-
concurrency/mutex.hfa (modified) (2 diffs)
-
concurrency/thread.cfa (modified) (3 diffs)
-
concurrency/thread.hfa (modified) (2 diffs)
-
heap.cfa (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/alarm.cfa
rfa35958 ree0bfa9 10 10 // Created On : Fri Jun 2 11:31:25 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 3 22:47:24 201913 // Update Count : 6 812 // Last Modified On : Fri May 25 06:25:47 2018 13 // Update Count : 67 14 14 // 15 15 … … 40 40 void __kernel_set_timer( Duration alarm ) { 41 41 verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm.tv); 42 setitimer( ITIMER_REAL, &(itimerval){ alarm }, 0p);42 setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL ); 43 43 } 44 44 … … 113 113 this->tail = &this->head; 114 114 } 115 head->next = 0p;115 head->next = NULL; 116 116 } 117 117 verify( validate( this ) ); … … 127 127 this->tail = it; 128 128 } 129 n->next = 0p;129 n->next = NULL; 130 130 131 131 verify( validate( this ) ); -
libcfa/src/concurrency/coroutine.hfa
rfa35958 ree0bfa9 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 3 22:47:58201913 // Update Count : 1012 // Last Modified On : Fri Jun 21 17:49:39 2019 13 // Update Count : 9 14 14 // 15 15 … … 38 38 void ^?{}( coroutine_desc & this ); 39 39 40 static inline void ?{}( coroutine_desc & this) { this{ "Anonymous Coroutine", 0p, 0 }; }41 static inline void ?{}( coroutine_desc & this, size_t stackSize) { this{ "Anonymous Coroutine", 0p, stackSize }; }40 static inline void ?{}( coroutine_desc & this) { this{ "Anonymous Coroutine", NULL, 0 }; } 41 static inline void ?{}( coroutine_desc & this, size_t stackSize) { this{ "Anonymous Coroutine", NULL, stackSize }; } 42 42 static inline void ?{}( coroutine_desc & this, void * storage, size_t storageSize ) { this{ "Anonymous Coroutine", storage, storageSize }; } 43 static inline void ?{}( coroutine_desc & this, const char * name) { this{ name, 0p, 0 }; }44 static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, 0p, stackSize }; }43 static inline void ?{}( coroutine_desc & this, const char * name) { this{ name, NULL, 0 }; } 44 static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, NULL, stackSize }; } 45 45 46 46 //----------------------------------------------------------------------------- … … 89 89 src->state = Active; 90 90 91 if( unlikely(src->cancellation != 0p) ) {91 if( unlikely(src->cancellation != NULL) ) { 92 92 _CtxCoroutine_Unwind(src->cancellation, src); 93 93 } … … 128 128 coroutine_desc * dst = get_coroutine(cor); 129 129 130 if( unlikely(dst->context.SP == 0p) ) {130 if( unlikely(dst->context.SP == NULL) ) { 131 131 __stack_prepare(&dst->stack, 65000); 132 132 CtxStart(&cor, CtxInvokeCoroutine); -
libcfa/src/concurrency/invoke.h
rfa35958 ree0bfa9 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 08:05:32201913 // Update Count : 4 312 // Last Modified On : Thu Nov 28 22:34:07 2019 13 // Update Count : 41 14 14 // 15 15 … … 208 208 209 209 static inline void ?{}(__monitor_group_t & this) { 210 (this.data){ 0p};210 (this.data){NULL}; 211 211 (this.size){0}; 212 212 (this.func){NULL}; -
libcfa/src/concurrency/kernel.cfa
rfa35958 ree0bfa9 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 3 21:46:54201913 // Update Count : 4 912 // Last Modified On : Sun Dec 1 17:52:57 2019 13 // Update Count : 45 14 14 // 15 15 … … 27 27 #include <unistd.h> 28 28 #include <limits.h> // PTHREAD_STACK_MIN 29 #include <sys/mman.h> // mprotect30 29 } 31 30 … … 282 281 283 282 thread_desc * readyThread = 0p; 284 for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) { 283 for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) 284 { 285 285 readyThread = nextThread( this->cltr ); 286 286 287 if(readyThread) { 287 if(readyThread) 288 { 288 289 verify( ! kernelTLS.preemption_state.enabled ); 289 290 … … 296 297 297 298 spin_count = 0; 298 } else { 299 } 300 else 301 { 299 302 // spin(this, &spin_count); 300 303 halt(this); … … 442 445 443 446 static void Abort( int ret, const char * func ) { 444 if ( ret ) { // pthread routines return errno values447 if ( ret ) { 445 448 abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) ); 446 449 } // if … … 452 455 Abort( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute 453 456 457 #ifdef __CFA_DEBUG__ 458 size_t guardsize; 459 Abort( pthread_attr_getguardsize( &attr, &guardsize ), "pthread_attr_getguardsize" ); 460 Abort( pthread_attr_setguardsize( &attr, guardsize ), "pthread_attr_setguardsize" ); 461 #endif 462 454 463 size_t stacksize; 455 // default stack size, normally defined by shell limit 456 Abort( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); 464 Abort( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); // default stack size, normally defined by shell limit 457 465 assert( stacksize >= PTHREAD_STACK_MIN ); 458 459 #ifdef __CFA_DEBUG__460 void * stack = memalign( __page_size, stacksize + __page_size );461 // pthread has no mechanism to create the guard page in user supplied stack.462 if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {463 abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );464 } // if465 #else466 466 void * stack = malloc( stacksize ); 467 #endif468 469 467 Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 470 468 -
libcfa/src/concurrency/kernel.hfa
rfa35958 ree0bfa9 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 07:54:51201913 // Update Count : 1 812 // Last Modified On : Thu Nov 28 21:24:12 2019 13 // Update Count : 17 14 14 // 15 15 … … 89 89 static inline void ?{}(FinishAction & this) { 90 90 this.action_code = No_Action; 91 this.thrd = 0p;92 this.lock = 0p;91 this.thrd = NULL; 92 this.lock = NULL; 93 93 } 94 94 static inline void ^?{}(FinishAction &) {} -
libcfa/src/concurrency/monitor.cfa
rfa35958 ree0bfa9 10 10 // Created On : Thd Feb 23 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 07:55:14 201913 // Update Count : 1012 // Last Modified On : Fri Mar 30 14:30:26 2018 13 // Update Count : 9 14 14 // 15 15 … … 363 363 this.waiting_thread = waiting_thread; 364 364 this.count = count; 365 this.next = 0p;365 this.next = NULL; 366 366 this.user_info = user_info; 367 367 } … … 369 369 void ?{}(__condition_criterion_t & this ) with( this ) { 370 370 ready = false; 371 target = 0p;372 owner = 0p;373 next = 0p;371 target = NULL; 372 owner = NULL; 373 next = NULL; 374 374 } 375 375 … … 378 378 this.target = target; 379 379 this.owner = &owner; 380 this.next = 0p;380 this.next = NULL; 381 381 } 382 382 … … 387 387 388 388 // Check that everything is as expected 389 assertf( this.monitors != 0p, "Waiting with no monitors (%p)", this.monitors );389 assertf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors ); 390 390 verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count ); 391 391 verifyf( this.monitor_count < 32u, "Excessive monitor count (%"PRIiFAST16")", this.monitor_count ); … … 449 449 450 450 // Lock all monitors 451 lock_all( this.monitors, 0p, count );451 lock_all( this.monitors, NULL, count ); 452 452 453 453 //Pop the head of the waiting queue … … 471 471 472 472 //Check that everything is as expected 473 verifyf( this.monitors != 0p, "Waiting with no monitors (%p)", this.monitors );473 verifyf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors ); 474 474 verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count ); 475 475 … … 674 674 675 675 static inline void reset_mask( monitor_desc * this ) { 676 this->mask.accepted = 0p;677 this->mask.data = 0p;676 this->mask.accepted = NULL; 677 this->mask.data = NULL; 678 678 this->mask.size = 0; 679 679 } … … 816 816 } 817 817 818 __cfaabi_dbg_print_safe( "Kernel : Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : 0p);819 return ready2run ? node->waiting_thread : 0p;818 __cfaabi_dbg_print_safe( "Kernel : Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : NULL ); 819 return ready2run ? node->waiting_thread : NULL; 820 820 } 821 821 … … 824 824 if( !this.monitors ) { 825 825 // __cfaabi_dbg_print_safe( "Branding\n" ); 826 assertf( thrd->monitors.data != 0p, "No current monitor to brand condition %p", thrd->monitors.data );826 assertf( thrd->monitors.data != NULL, "No current monitor to brand condition %p", thrd->monitors.data ); 827 827 this.monitor_count = thrd->monitors.size; 828 828 -
libcfa/src/concurrency/monitor.hfa
rfa35958 ree0bfa9 10 10 // Created On : Thd Feb 23 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 07:55:32 201913 // Update Count : 1 112 // Last Modified On : Sat Oct 7 18:06:45 2017 13 // Update Count : 10 14 14 // 15 15 … … 31 31 entry_queue{}; 32 32 signal_stack{}; 33 owner = 0p;33 owner = NULL; 34 34 recursion = 0; 35 mask.accepted = 0p;36 mask.data = 0p;35 mask.accepted = NULL; 36 mask.data = NULL; 37 37 mask.size = 0; 38 dtor_node = 0p;38 dtor_node = NULL; 39 39 } 40 40 … … 122 122 123 123 static inline void ?{}( condition & this ) { 124 this.monitors = 0p;124 this.monitors = NULL; 125 125 this.monitor_count = 0; 126 126 } -
libcfa/src/concurrency/mutex.cfa
rfa35958 ree0bfa9 11 11 // Author : Thierry Delisle 12 12 // Created On : Fri May 25 01:37:11 2018 13 // Last Modified By : Peter A. Buhr14 // Last Modified On : Wed Dec 4 09:16:39 201915 // Update Count : 113 // Last Modified By : Thierry Delisle 14 // Last Modified On : Fri May 25 01:37:51 2018 15 // Update Count : 0 16 16 // 17 17 … … 73 73 this.lock{}; 74 74 this.blocked_threads{}; 75 this.owner = 0p;75 this.owner = NULL; 76 76 this.recursion_count = 0; 77 77 } … … 83 83 void lock(recursive_mutex_lock & this) with(this) { 84 84 lock( lock __cfaabi_dbg_ctx2 ); 85 if( owner == 0p) {85 if( owner == NULL ) { 86 86 owner = kernelTLS.this_thread; 87 87 recursion_count = 1; … … 101 101 bool ret = false; 102 102 lock( lock __cfaabi_dbg_ctx2 ); 103 if( owner == 0p) {103 if( owner == NULL ) { 104 104 owner = kernelTLS.this_thread; 105 105 recursion_count = 1; -
libcfa/src/concurrency/mutex.hfa
rfa35958 ree0bfa9 11 11 // Author : Thierry Delisle 12 12 // Created On : Fri May 25 01:24:09 2018 13 // Last Modified By : Peter A. Buhr14 // Last Modified On : Wed Dec 4 09:16:53 201915 // Update Count : 113 // Last Modified By : Thierry Delisle 14 // Last Modified On : Fri May 25 01:24:12 2018 15 // Update Count : 0 16 16 // 17 17 … … 110 110 111 111 static inline void ?{}(lock_scope(L) & this) { 112 this.locks = 0p;112 this.locks = NULL; 113 113 this.count = 0; 114 114 } -
libcfa/src/concurrency/thread.cfa
rfa35958 ree0bfa9 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 09:17:49 201913 // Update Count : 912 // Last Modified On : Fri Mar 30 17:19:52 2018 13 // Update Count : 8 14 14 // 15 15 … … 33 33 // Thread ctors and dtors 34 34 void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) { 35 context{ 0p, 0p};35 context{ NULL, NULL }; 36 36 self_cor{ name, storage, storageSize }; 37 37 state = Start; … … 41 41 self_mon_p = &self_mon; 42 42 curr_cluster = &cl; 43 next = 0p;43 next = NULL; 44 44 45 node.next = 0p;46 node.prev = 0p;45 node.next = NULL; 46 node.prev = NULL; 47 47 doregister(curr_cluster, this); 48 48 -
libcfa/src/concurrency/thread.hfa
rfa35958 ree0bfa9 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 09:18:14201913 // Update Count : 612 // Last Modified On : Fri Jun 21 17:51:33 2019 13 // Update Count : 5 14 14 // 15 15 … … 61 61 void ^?{}(thread_desc & this); 62 62 63 static inline void ?{}(thread_desc & this) { this{ "Anonymous Thread", *mainCluster, 0p, 65000 }; }64 static inline void ?{}(thread_desc & this, size_t stackSize ) { this{ "Anonymous Thread", *mainCluster, 0p, stackSize }; }63 static inline void ?{}(thread_desc & this) { this{ "Anonymous Thread", *mainCluster, NULL, 65000 }; } 64 static inline void ?{}(thread_desc & this, size_t stackSize ) { this{ "Anonymous Thread", *mainCluster, NULL, stackSize }; } 65 65 static inline void ?{}(thread_desc & this, void * storage, size_t storageSize ) { this{ "Anonymous Thread", *mainCluster, storage, storageSize }; } 66 static inline void ?{}(thread_desc & this, struct cluster & cl ) { this{ "Anonymous Thread", cl, 0p, 65000 }; }67 static inline void ?{}(thread_desc & this, struct cluster & cl, size_t stackSize ) { this{ "Anonymous Thread", cl, 0p, stackSize }; }66 static inline void ?{}(thread_desc & this, struct cluster & cl ) { this{ "Anonymous Thread", cl, NULL, 65000 }; } 67 static inline void ?{}(thread_desc & this, struct cluster & cl, size_t stackSize ) { this{ "Anonymous Thread", cl, NULL, stackSize }; } 68 68 static inline void ?{}(thread_desc & this, struct cluster & cl, void * storage, size_t storageSize ) { this{ "Anonymous Thread", cl, storage, storageSize }; } 69 static inline void ?{}(thread_desc & this, const char * const name) { this{ name, *mainCluster, 0p, 65000 }; }70 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl ) { this{ name, cl, 0p, 65000 }; }71 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, 0p, stackSize }; }69 static inline void ?{}(thread_desc & this, const char * const name) { this{ name, *mainCluster, NULL, 65000 }; } 70 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl ) { this{ name, cl, NULL, 65000 }; } 71 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, NULL, stackSize }; } 72 72 73 73 //----------------------------------------------------------------------------- -
libcfa/src/heap.cfa
rfa35958 ree0bfa9 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 3 13:58:44201913 // Update Count : 64 212 // Last Modified On : Fri Nov 29 17:33:58 2019 13 // Update Count : 641 14 14 // 15 15 … … 855 855 #endif // __STATISTICS__ 856 856 857 // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned. 858 if ( unlikely( size == 0 ) ) { free( oaddr ); return mallocNoStats( size ); } // special cases 857 if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases 859 858 if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size ); 860 859 … … 1083 1082 #endif // __STATISTICS__ 1084 1083 1085 // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned. 1086 if ( unlikely( size == 0 ) ) { free( oaddr ); return mallocNoStats( size ); } // special cases 1084 if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases 1087 1085 if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size ); 1088 1086
Note:
See TracChangeset
for help on using the changeset viewer.