Changeset 4e6fb8e for src/libcfa/concurrency/alarm.c
- Timestamp:
- Jun 16, 2017, 4:45:20 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- ec35498
- Parents:
- 70c2df8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/alarm.c
r70c2df8 r4e6fb8e 89 89 } 90 90 91 LIB_DEBUG_DO( bool validate( alarm_list_t * this ) { 92 alarm_node_t ** it = &this->head; 93 while( (*it) ) { 94 it = &(*it)->next; 95 } 96 97 return it == this->tail; 98 }) 99 91 100 static inline void insert_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t p ) { 92 101 assert( !n->next ); … … 98 107 } 99 108 *p = n; 109 110 LIB_DEBUG_DO( assert( validate( this ) ) ); 100 111 } 101 112 … … 107 118 108 119 insert_at( this, n, it ); 120 121 LIB_DEBUG_DO( assert( validate( this ) ) ); 109 122 } 110 123 … … 118 131 head->next = NULL; 119 132 } 133 LIB_DEBUG_DO( assert( validate( this ) ) ); 120 134 return head; 121 135 } … … 123 137 static inline void remove_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t it ) { 124 138 assert( it ); 125 assert( (*it) ->next== n );126 127 (*it) ->next= n->next;139 assert( (*it) == n ); 140 141 (*it) = n->next; 128 142 if( !n-> next ) { 129 143 this->tail = it; 130 144 } 131 145 n->next = NULL; 146 147 LIB_DEBUG_DO( assert( validate( this ) ) ); 132 148 } 133 149 134 150 static inline void remove( alarm_list_t * this, alarm_node_t * n ) { 135 151 alarm_node_t ** it = &this->head; 136 while( (*it) && (*it) ->next!= n ) {152 while( (*it) && (*it) != n ) { 137 153 it = &(*it)->next; 138 154 } 139 155 156 LIB_DEBUG_DO( assert( validate( this ) ) ); 157 140 158 if( *it ) { remove_at( this, n, it ); } 159 160 LIB_DEBUG_DO( assert( validate( this ) ) ); 141 161 } 142 162 … … 145 165 assert( !systemProcessor->pending_alarm ); 146 166 lock( &systemProcessor->alarm_lock ); 167 LIB_DEBUG_DO( assert( validate( &systemProcessor->alarms ) ) ); 147 168 { 148 169 bool first = !systemProcessor->alarms.head; … … 158 179 unlock( &systemProcessor->alarm_lock ); 159 180 this->set = true; 160 enable_interrupts( );181 enable_interrupts( __PRETTY_FUNCTION__ ); 161 182 } 162 183 163 184 void unregister_self( alarm_node_t * this ) { 185 LIB_DEBUG_DO( 186 char text[256]; 187 __attribute__((unused)) int len = snprintf( text, 256, "Kernel : unregister %p start\n", this ); 188 LIB_DEBUG_WRITE( STDERR_FILENO, text, len ); 189 ); 164 190 disable_interrupts(); 165 191 lock( &systemProcessor->alarm_lock ); 192 LIB_DEBUG_DO( assert( validate( &systemProcessor->alarms ) ) ); 166 193 remove( &systemProcessor->alarms, this ); 167 194 unlock( &systemProcessor->alarm_lock ); 168 195 disable_interrupts(); 169 196 this->set = false; 170 } 197 LIB_DEBUG_DO( 198 len = snprintf( text, 256, "Kernel : unregister %p end\n", this ); 199 LIB_DEBUG_WRITE( STDERR_FILENO, text, len ); 200 ); 201 }
Note: See TracChangeset
for help on using the changeset viewer.