Changes in / [3959595:be73f30]
- Files:
-
- 9 edited
-
libcfa/src/concurrency/alarm.cfa (modified) (2 diffs)
-
libcfa/src/concurrency/alarm.hfa (modified) (3 diffs)
-
libcfa/src/concurrency/locks.cfa (modified) (13 diffs)
-
libcfa/src/concurrency/locks.hfa (modified) (5 diffs)
-
libcfa/src/concurrency/preemption.cfa (modified) (1 diff)
-
src/InitTweak/FixGlobalInit.cc (modified) (1 diff)
-
src/InitTweak/FixInitNew.cpp (modified) (2 diffs)
-
src/InitTweak/InitTweak.cc (modified) (1 diff)
-
src/InitTweak/InitTweak.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/alarm.cfa
r3959595 rbe73f30 45 45 //============================================================================================= 46 46 47 void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period ) with( this ) {47 void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period ) with( this ) { 48 48 this.thrd = thrd; 49 49 this.alarm = alarm; 50 50 this.period = period; 51 51 set = false; 52 type = User;52 kernel_alarm = false; 53 53 } 54 54 … … 58 58 this.period = period; 59 59 set = false; 60 type = Kernel; 61 } 62 void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period, Alarm_Callback callback ) with( this ) { 63 this.thrd = thrd; 64 this.alarm = alarm; 65 this.period = period; 66 this.callback = callback; 67 set = false; 68 type = Callback; 60 kernel_alarm = true; 69 61 } 70 62 -
libcfa/src/concurrency/alarm.hfa
r3959595 rbe73f30 39 39 //============================================================================================= 40 40 41 enum alarm_type{ Kernel = 0, User = 1, Callback = 2 };42 43 struct alarm_node_t;44 45 typedef void (*Alarm_Callback)(alarm_node_t & );46 47 41 struct alarm_node_t { 48 42 Time alarm; // time when alarm goes off … … 56 50 }; 57 51 58 Alarm_Callback callback;59 60 52 bool set :1; // whether or not the alarm has be registered 61 enum alarm_type type; // true if this is not a user defined alarm53 bool kernel_alarm :1; // true if this is not a user defined alarm 62 54 }; 63 55 DLISTED_MGD_IMPL_OUT(alarm_node_t) … … 65 57 void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period ); 66 58 void ?{}( alarm_node_t & this, processor * proc, Time alarm, Duration period ); 67 void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period, Alarm_Callback callback );68 59 void ^?{}( alarm_node_t & this ); 69 60 -
libcfa/src/concurrency/locks.cfa
r3959595 rbe73f30 15 15 this.t = t; 16 16 this.lock = 0p; 17 this.listed = false;18 17 } 19 18 … … 22 21 this.info = info; 23 22 this.lock = 0p; 24 this.listed = false;25 23 } 26 24 … … 80 78 if ( owner == thrd && !multi_acquisition) { 81 79 fprintf(stderr, "A single acquisition lock holder attempted to reacquire the lock resulting in a deadlock."); // Possibly throw instead 82 exit(EXIT_FAILURE);80 exit(EXIT_FAILURE); 83 81 } else if ( owner != 0p && owner != thrd ) { 84 82 append( blocked_threads, thrd ); 85 83 wait_count++; 86 84 unlock( lock ); 87 park( );85 park( __cfaabi_dbg_ctx ); 88 86 } else if ( owner == thrd && multi_acquisition ) { 89 87 recursion_count++; … … 117 115 fprintf( stderr, "There was an attempt to release a lock that isn't held" ); 118 116 return; 119 } else if ( strict_owner && active_thread() ) {117 } else if ( strict_owner && owner != active_thread() ) { 120 118 fprintf( stderr, "A thread other than the owner attempted to release an owner lock" ); 121 119 return; … … 127 125 recursion_count = ( thrd && multi_acquisition ? 1 : 0 ); 128 126 wait_count--; 129 unpark( thrd );127 unpark( thrd __cfaabi_dbg_ctx2 ); 130 128 } 131 129 unlock( lock ); … … 154 152 owner = t; 155 153 if ( multi_acquisition ) recursion_count = 1; 156 #if !defined( __CFA_NO_STATISTICS__ ) 157 kernelTLS.this_stats = t->curr_cluster->stats; 158 #endif 159 unpark( t ); 154 unpark( t __cfaabi_dbg_ctx2 ); 160 155 unlock( lock ); 161 156 } … … 166 161 if ( owner == 0p ){ // no owner implies lock isn't held 167 162 fprintf( stderr, "A lock that is not held was passed to a synchronization lock" ); 168 } else if ( strict_owner && active_thread() ) {163 } else if ( strict_owner && owner != active_thread() ) { 169 164 fprintf( stderr, "A thread other than the owner of a lock passed it to a synchronization lock" ); 170 165 } else { … … 173 168 recursion_count = ( thrd && multi_acquisition ? 1 : 0 ); 174 169 wait_count--; 175 unpark( thrd );170 unpark( thrd __cfaabi_dbg_ctx2 ); 176 171 } 177 172 unlock( lock ); … … 182 177 /////////////////////////////////////////////////////////////////// 183 178 184 // This is temporary until an inheritance bug is fixed 179 // In an ideal world this may not be necessary 180 // Is it possible for nominal inheritance to inherit traits?? 181 // If that occurs we would avoid all this extra code 185 182 186 183 void lock( mutex_lock & this ){ … … 233 230 234 231 /////////////////////////////////////////////////////////////////// 235 //// condition variable232 //// Synchronization Locks 236 233 /////////////////////////////////////////////////////////////////// 237 234 238 235 forall(dtype L | is_blocking_lock(L)) { 239 240 void timeout_handler ( alarm_node_wrap(L) & this ) with( this ) { 241 // This condition_variable member is called from the kernel, and therefore, cannot block, but it can spin. 242 lock( cond->lock __cfaabi_dbg_ctx2 ); 243 if ( (*i)->listed ) { // is thread on queue 244 info_thread(L) * copy = *i; 245 remove( cond->blocked_threads, i ); //remove this thread O(1) 246 cond->wait_count--; 247 if( !copy->lock ) { 248 unlock( cond->lock ); 249 #if !defined( __CFA_NO_STATISTICS__ ) 250 #warning unprotected access to tls TODO discuss this 251 kernelTLS.this_stats = copy->t->curr_cluster->stats; 252 #endif 253 unpark( copy->t ); 254 } else { 255 add_(*copy->lock, copy->t); // call lock's add_ 256 } 257 } 258 unlock( cond->lock ); 259 } 260 261 void alarm_node_wrap_cast( alarm_node_t & a ) { 262 timeout_handler( (alarm_node_wrap(L) &)a ); 263 } 264 265 void ?{}( condition_variable(L) & this ){ 236 void ?{}( synchronization_lock(L) & this, bool reacquire_after_signal ){ 266 237 this.lock{}; 267 238 this.blocked_threads{}; 268 239 this.count = 0; 240 this.reacquire_after_signal = reacquire_after_signal; 241 } 242 243 void ^?{}( synchronization_lock(L) & this ){ 244 // default 245 } 246 247 void ?{}( condition_variable(L) & this ){ 248 ((synchronization_lock(L) &)this){ true }; 269 249 } 270 250 … … 273 253 } 274 254 275 void ?{}( alarm_node_wrap(L) & this, $thread * thrd, Time alarm, Duration period, Alarm_Callback callback ){276 this.alarm_node{ thrd, alarm, period, callback};277 } 278 279 void ^?{}( alarm_node_wrap(L) & this ){280 // default 281 } 282 283 bool notify_one( condition_variable(L) & this ) with( this ) {255 void ?{}( thread_queue(L) & this ){ 256 ((synchronization_lock(L) &)this){ false }; 257 } 258 259 void ^?{}( thread_queue(L) & this ){ 260 // default 261 } 262 263 bool notify_one( synchronization_lock(L) & this ) with( this ) { 284 264 lock( lock __cfaabi_dbg_ctx2 ); 285 265 bool ret = !!blocked_threads; 286 266 info_thread(L) * popped = pop_head( blocked_threads ); 287 popped->listed = false;288 267 if(popped != 0p) { 289 count--; 290 if (popped->lock) { 268 if( reacquire_after_signal ){ 291 269 add_(*popped->lock, popped->t); 292 270 } else { 293 unpark(popped->t); 271 unpark( 272 popped->t __cfaabi_dbg_ctx2 273 ); 294 274 } 295 275 } … … 298 278 } 299 279 300 bool notify_all( condition_variable(L) & this ) with(this) {280 bool notify_all( synchronization_lock(L) & this ) with(this) { 301 281 lock( lock __cfaabi_dbg_ctx2 ); 302 282 bool ret = blocked_threads ? true : false; 303 283 while( blocked_threads ) { 304 284 info_thread(L) * popped = pop_head( blocked_threads ); 305 popped->listed = false;306 285 if(popped != 0p){ 307 count--; 308 if (popped->lock) { 286 if( reacquire_after_signal ){ 309 287 add_(*popped->lock, popped->t); 310 288 } else { 311 unpark(popped->t); 289 unpark( 290 popped->t __cfaabi_dbg_ctx2 291 ); 312 292 } 313 293 } … … 317 297 } 318 298 319 uintptr_t front( condition_variable(L) & this ) with(this) { 320 if(!blocked_threads) return NULL; 321 return peek(blocked_threads)->info; 322 } 323 324 bool empty( condition_variable(L) & this ) with(this) { 299 uintptr_t front( synchronization_lock(L) & this ) with(this) { 300 return (*peek(blocked_threads)).info; 301 } 302 303 bool empty( synchronization_lock(L) & this ) with(this) { 325 304 return blocked_threads ? false : true; 326 305 } 327 306 328 int counter( condition_variable(L) & this ) with(this) {307 int counter( synchronization_lock(L) & this ) with(this) { 329 308 return count; 330 309 } 331 310 332 // helper for wait()'s' without a timeout 333 void queue_info_thread( condition_variable(L) & this, info_thread(L) & i ) with(this) { 311 void queue_info_thread( synchronization_lock(L) & this, info_thread(L) & i ) with(this) { 312 lock( lock __cfaabi_dbg_ctx2 ); 313 append( blocked_threads, &i ); 314 count++; 315 unlock( lock ); 316 park( __cfaabi_dbg_ctx ); 317 } 318 319 320 void wait( synchronization_lock(L) & this ) with(this) { 321 info_thread( L ) i = { active_thread() }; 322 queue_info_thread( this, i ); 323 } 324 325 void wait( synchronization_lock(L) & this, uintptr_t info ) with(this) { 326 info_thread( L ) i = { active_thread(), info }; 327 queue_info_thread( this, i ); 328 } 329 // I still need to implement the time delay wait routines 330 bool wait( synchronization_lock(L) & this, Duration duration ) with(this) { 331 timeval tv = { time(0) }; 332 Time t = { tv }; 333 return wait( this, t + duration ); 334 } 335 336 bool wait( synchronization_lock(L) & this, uintptr_t info, Duration duration ) with(this) { 337 // TODO: ADD INFO 338 return wait( this, duration ); 339 } 340 341 bool wait( synchronization_lock(L) & this, Time time ) with(this) { 342 return false; //default 343 } 344 345 bool wait( synchronization_lock(L) & this, uintptr_t info, Time time ) with(this) { 346 // TODO: ADD INFO 347 return wait( this, time ); 348 } 349 350 void queue_info_thread_unlock( synchronization_lock(L) & this, L & l, info_thread(L) & i ) with(this) { 334 351 lock( lock __cfaabi_dbg_ctx2 ); 335 352 append( this.blocked_threads, &i ); 336 353 count++; 337 i.listed = true; 338 size_t recursion_count; 339 if (i.lock) { 340 recursion_count = get_recursion_count(*i.lock); 341 remove_( *i.lock ); 342 } 343 344 unlock( lock ); 345 park( ); // blocks here 346 347 if (i.lock) set_recursion_count(*i.lock, recursion_count); // resets recursion count here after waking 348 } 349 350 // helper for wait()'s' with a timeout 351 void queue_info_thread_timeout( condition_variable(L) & this, info_thread(L) & info, Time t ) with(this) { 352 lock( lock __cfaabi_dbg_ctx2 ); 353 354 info_thread(L) * queue_ptr = &info; 355 356 alarm_node_wrap(L) node_wrap = { info.t, t, 0`s, alarm_node_wrap_cast }; 357 node_wrap.cond = &this; 358 node_wrap.i = &queue_ptr; 359 360 register_self( &node_wrap.alarm_node ); 361 362 append( blocked_threads, queue_ptr ); 363 info.listed = true; 364 count++; 365 366 size_t recursion_count; 367 if (info.lock) { 368 recursion_count = get_recursion_count(*info.lock); 369 remove_( *info.lock ); 370 } 371 372 unlock( lock ); 373 park(); 374 375 if (info.lock) set_recursion_count(*info.lock, recursion_count); 376 } 377 378 void wait( condition_variable(L) & this ) with(this) { 379 info_thread( L ) i = { active_thread() }; 380 queue_info_thread( this, i ); 381 } 382 383 void wait( condition_variable(L) & this, uintptr_t info ) with(this) { 384 info_thread( L ) i = { active_thread(), info }; 385 queue_info_thread( this, i ); 386 } 387 388 void wait( condition_variable(L) & this, Duration duration ) with(this) { 389 info_thread( L ) i = { active_thread() }; 390 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 391 } 392 393 void wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) { 394 info_thread( L ) i = { active_thread(), info }; 395 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 396 } 397 398 void wait( condition_variable(L) & this, Time time ) with(this) { 399 info_thread( L ) i = { active_thread() }; 400 queue_info_thread_timeout(this, i, time); 401 } 402 403 void wait( condition_variable(L) & this, uintptr_t info, Time time ) with(this) { 404 info_thread( L ) i = { active_thread(), info }; 405 queue_info_thread_timeout(this, i, time); 406 } 407 408 void wait( condition_variable(L) & this, L & l ) with(this) { 354 i.lock = &l; 355 size_t recursion_count = get_recursion_count(l); 356 remove_( l ); 357 unlock( lock ); 358 park( __cfaabi_dbg_ctx ); // blocks here 359 360 set_recursion_count(l, recursion_count); // resets recursion count here after waking 361 } 362 363 void wait( synchronization_lock(L) & this, L & l ) with(this) { 409 364 info_thread(L) i = { active_thread() }; 410 i.lock = &l; 411 queue_info_thread( this, i ); 412 } 413 414 void wait( condition_variable(L) & this, L & l, uintptr_t info ) with(this) { 365 queue_info_thread_unlock( this, l, i ); 366 } 367 368 void wait( synchronization_lock(L) & this, L & l, uintptr_t info ) with(this) { 415 369 info_thread(L) i = { active_thread(), info }; 416 i.lock = &l; 417 queue_info_thread( this, i ); 418 } 419 420 void wait( condition_variable(L) & this, L & l, Duration duration ) with(this) { 421 info_thread(L) i = { active_thread() }; 422 i.lock = &l; 423 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 424 } 425 426 void wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) { 427 info_thread(L) i = { active_thread(), info }; 428 i.lock = &l; 429 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 430 } 431 432 void wait( condition_variable(L) & this, L & l, Time time ) with(this) { 433 info_thread(L) i = { active_thread() }; 434 i.lock = &l; 435 queue_info_thread_timeout(this, i, time ); 436 } 437 438 void wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ) with(this) { 439 info_thread(L) i = { active_thread(), info }; 440 i.lock = &l; 441 queue_info_thread_timeout(this, i, time ); 442 } 443 } 370 queue_info_thread_unlock( this, l, i ); 371 } 372 373 bool wait( synchronization_lock(L) & this, L & l, Duration duration ) with(this) { 374 timeval tv = { time(0) }; 375 Time t = { tv }; 376 return wait( this, l, t + duration ); 377 } 378 379 bool wait( synchronization_lock(L) & this, L & l, uintptr_t info, Duration duration ) with(this) { 380 // TODO: ADD INFO 381 return wait( this, l, duration ); 382 } 383 384 bool wait( synchronization_lock(L) & this, L & l, Time time ) with(this) { 385 return false; //default 386 } 387 388 bool wait( synchronization_lock(L) & this, L & l, uintptr_t info, Time time ) with(this) { 389 // TODO: ADD INFO 390 return wait( this, l, time ); 391 } 392 } 393 394 /////////////////////////////////////////////////////////////////// 395 //// condition lock alternative approach 396 /////////////////////////////////////////////////////////////////// 397 398 // the solution below is less efficient but does not require the lock to have a specific add/remove routine 399 400 /////////////////////////////////////////////////////////////////// 401 //// is_simple_lock 402 /////////////////////////////////////////////////////////////////// 403 404 forall(dtype L | is_simple_lock(L)) { 405 void ?{}( condition_lock(L) & this ){ 406 // default 407 } 408 409 void ^?{}( condition_lock(L) & this ){ 410 // default 411 } 412 413 bool notify_one( condition_lock(L) & this ) with(this) { 414 return notify_one( c_var ); 415 } 416 417 bool notify_all( condition_lock(L) & this ) with(this) { 418 return notify_all( c_var ); 419 } 420 421 void wait( condition_lock(L) & this, L & l ) with(this) { 422 lock( m_lock ); 423 size_t recursion = get_recursion_count( l ); 424 unlock( l ); 425 wait( c_var, m_lock ); 426 lock( l ); 427 set_recursion_count( l , recursion ); 428 unlock( m_lock ); 429 } 430 } -
libcfa/src/concurrency/locks.hfa
r3959595 rbe73f30 1 #pragma once2 3 1 #include <stdbool.h> 4 2 … … 12 10 #include "time.hfa" 13 11 #include <sys/time.h> 14 #include "alarm.hfa"15 12 16 13 /////////////////////////////////////////////////////////////////// … … 35 32 info_thread(L) * next; 36 33 L * lock; 37 bool listed; // true if info_thread is on queue, false otherwise;38 34 }; 39 35 … … 123 119 /////////////////////////////////////////////////////////////////// 124 120 forall(dtype L | is_blocking_lock(L)) { 125 struct condition_variable{121 struct synchronization_lock { 126 122 // Spin lock used for mutual exclusion 127 123 __spinlock_t lock; … … 132 128 // Count of current blocked threads 133 129 int count; 134 }; 130 131 // If true threads will reacquire the lock they block on upon waking 132 bool reacquire_after_signal; 133 }; 134 135 struct condition_variable { 136 inline synchronization_lock(L); 137 }; 138 139 struct thread_queue { 140 inline synchronization_lock(L); 141 }; 142 143 144 void ?{}( synchronization_lock(L) & this, bool multi_acquisition, bool strict_owner ); 145 void ^?{}( synchronization_lock(L) & this ); 135 146 136 147 void ?{}( condition_variable(L) & this ); 137 148 void ^?{}( condition_variable(L) & this ); 138 149 139 struct alarm_node_wrap { 140 alarm_node_t alarm_node; 141 142 condition_variable(L) * cond; 143 144 info_thread(L) ** i; 145 }; 146 147 void ?{}( alarm_node_wrap(L) & this, $thread * thrd, Time alarm, Duration period, Alarm_Callback callback ); 148 void ^?{}( alarm_node_wrap(L) & this ); 149 150 void alarm_node_callback( alarm_node_wrap(L) & this ); 151 152 void alarm_node_wrap_cast( alarm_node_t & a ); 153 154 bool notify_one( condition_variable(L) & this ); 155 bool notify_all( condition_variable(L) & this ); 156 157 uintptr_t front( condition_variable(L) & this ); 158 159 bool empty( condition_variable(L) & this ); 160 int counter( condition_variable(L) & this ); 161 162 // TODO: look into changing timout routines to return bool showing if signalled or woken by kernel 163 void wait( condition_variable(L) & this ); 164 void wait( condition_variable(L) & this, uintptr_t info ); 165 void wait( condition_variable(L) & this, Duration duration ); 166 void wait( condition_variable(L) & this, uintptr_t info, Duration duration ); 167 void wait( condition_variable(L) & this, Time time ); 168 void wait( condition_variable(L) & this, uintptr_t info, Time time ); 169 170 void wait( condition_variable(L) & this, L & l ); 171 void wait( condition_variable(L) & this, L & l, uintptr_t info ); 172 void wait( condition_variable(L) & this, L & l, Duration duration ); 173 void wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ); 174 void wait( condition_variable(L) & this, L & l, Time time ); 175 void wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ); 150 void ?{}( thread_queue(L) & this ); 151 void ^?{}( thread_queue(L) & this ); 152 153 bool notify_one( synchronization_lock(L) & this ); 154 bool notify_all( synchronization_lock(L) & this ); 155 156 uintptr_t front( synchronization_lock(L) & this ); 157 158 bool empty( synchronization_lock(L) & this ); 159 int counter( synchronization_lock(L) & this ); 160 161 // wait functions that are not passed a mutex lock 162 void wait( synchronization_lock(L) & this ); 163 void wait( synchronization_lock(L) & this, uintptr_t info ); 164 bool wait( synchronization_lock(L) & this, Duration duration ); 165 bool wait( synchronization_lock(L) & this, uintptr_t info, Duration duration ); 166 bool wait( synchronization_lock(L) & this, Time time ); 167 bool wait( synchronization_lock(L) & this, uintptr_t info, Time time ); 168 169 // wait functions that are passed a lock 170 bool notify_one( synchronization_lock(L) & this, L & l ); 171 bool notify_all( synchronization_lock(L) & this, L & l ); 172 173 void wait( synchronization_lock(L) & this, L & l ); 174 void wait( synchronization_lock(L) & this, L & l, uintptr_t info ); 175 bool wait( synchronization_lock(L) & this, L & l, Duration duration ); 176 bool wait( synchronization_lock(L) & this, L & l, uintptr_t info, Duration duration ); 177 bool wait( synchronization_lock(L) & this, L & l, Time time ); 178 bool wait( synchronization_lock(L) & this, L & l, uintptr_t info, Time time ); 176 179 } 180 181 /////////////////////////////////////////////////////////////////// 182 //// condition lock alternative approach 183 /////////////////////////////////////////////////////////////////// 184 185 186 /////////////////////////////////////////////////////////////////// 187 //// is_simple_lock 188 /////////////////////////////////////////////////////////////////// 189 190 trait is_simple_lock(dtype L | sized(L)) { 191 void lock( L & ); // For synchronization locks to use when acquiring 192 void unlock( L & ); // For synchronization locks to use when releasing 193 size_t get_recursion_count( L & ); // to get recursion count for cond lock to reset after waking 194 void set_recursion_count( L &, size_t recursion ); // to set recursion count after getting signalled; 195 }; 196 197 forall(dtype L | is_simple_lock(L)) { 198 struct condition_lock { 199 // Spin lock used for mutual exclusion 200 mutex_lock m_lock; 201 202 condition_variable( mutex_lock ) c_var; 203 }; 204 205 void ?{}( condition_lock(L) & this ); 206 void ^?{}( condition_lock(L) & this ); 207 208 bool notify_one( condition_lock(L) & this ); 209 bool notify_all( condition_lock(L) & this ); 210 void wait( condition_lock(L) & this, L & l ); 211 } -
libcfa/src/concurrency/preemption.cfa
r3959595 rbe73f30 105 105 106 106 // Check if this is a kernel 107 if( node-> type == Kernel) {107 if( node->kernel_alarm ) { 108 108 preempt( node->proc ); 109 109 } 110 else if( node->type == User ){110 else { 111 111 timeout( node->thrd ); 112 }113 else {114 node->callback(*node);115 112 } 116 113 -
src/InitTweak/FixGlobalInit.cc
r3959595 rbe73f30 183 183 } // if 184 184 if ( const ast::Stmt * ctor = ctorInit->ctor ) { 185 addDataSectionAttribute(mutDecl);186 185 initStmts.push_back( ctor ); 187 186 mutDecl->init = nullptr; -
src/InitTweak/FixInitNew.cpp
r3959595 rbe73f30 864 864 if ( const ast::Stmt * ctor = ctorInit->ctor ) { 865 865 if ( objDecl->storage.is_static ) { 866 addDataSectionAttribute(objDecl);867 866 // originally wanted to take advantage of gcc nested functions, but 868 867 // we get memory errors with this approach. To remedy this, the static … … 948 947 objDecl->name = objDecl->name + staticNamer.newName(); 949 948 objDecl->mangleName = Mangle::mangle( objDecl ); 950 objDecl->init = nullptr;951 949 952 950 // xxx - temporary hack: need to return a declaration, but want to hoist the current object out of this scope -
src/InitTweak/InitTweak.cc
r3959595 rbe73f30 1113 1113 } 1114 1114 1115 void addDataSectionAttribute( ast::ObjectDecl * objDecl ) {1116 auto strLitT = new ast::PointerType(new ast::BasicType(ast::BasicType::Char));1117 objDecl->attributes.push_back(new ast::Attribute("section", {new ast::ConstantExpr(objDecl->location, strLitT, "\".data#\"", std::nullopt)}));1118 }1119 1120 1115 } -
src/InitTweak/InitTweak.h
r3959595 rbe73f30 119 119 void addDataSectonAttribute( ObjectDecl * objDecl ); 120 120 121 void addDataSectionAttribute( ast::ObjectDecl * objDecl );122 123 121 class InitExpander_old { 124 122 public:
Note:
See TracChangeset
for help on using the changeset viewer.