Changeset 3959595
- Timestamp:
- Nov 5, 2020, 9:52:11 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 231b18f, b5d51b0
- Parents:
- be73f30 (diff), 3febb2d (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. - Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified libcfa/src/concurrency/alarm.cfa ¶
rbe73f30 r3959595 45 45 //============================================================================================= 46 46 47 void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period 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 kernel_alarm = false;52 type = User; 53 53 } 54 54 … … 58 58 this.period = period; 59 59 set = false; 60 kernel_alarm = true; 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; 61 69 } 62 70 -
TabularUnified libcfa/src/concurrency/alarm.hfa ¶
rbe73f30 r3959595 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 41 47 struct alarm_node_t { 42 48 Time alarm; // time when alarm goes off … … 50 56 }; 51 57 58 Alarm_Callback callback; 59 52 60 bool set :1; // whether or not the alarm has be registered 53 bool kernel_alarm :1; // true if this is not a user defined alarm61 enum alarm_type type; // true if this is not a user defined alarm 54 62 }; 55 63 DLISTED_MGD_IMPL_OUT(alarm_node_t) … … 57 65 void ?{}( alarm_node_t & this, $thread * thrd, Time alarm, Duration period ); 58 66 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 ); 59 68 void ^?{}( alarm_node_t & this ); 60 69 -
TabularUnified libcfa/src/concurrency/locks.cfa ¶
rbe73f30 r3959595 15 15 this.t = t; 16 16 this.lock = 0p; 17 this.listed = false; 17 18 } 18 19 … … 21 22 this.info = info; 22 23 this.lock = 0p; 24 this.listed = false; 23 25 } 24 26 … … 78 80 if ( owner == thrd && !multi_acquisition) { 79 81 fprintf(stderr, "A single acquisition lock holder attempted to reacquire the lock resulting in a deadlock."); // Possibly throw instead 80 82 exit(EXIT_FAILURE); 81 83 } else if ( owner != 0p && owner != thrd ) { 82 84 append( blocked_threads, thrd ); 83 85 wait_count++; 84 86 unlock( lock ); 85 park( __cfaabi_dbg_ctx);87 park( ); 86 88 } else if ( owner == thrd && multi_acquisition ) { 87 89 recursion_count++; … … 115 117 fprintf( stderr, "There was an attempt to release a lock that isn't held" ); 116 118 return; 117 } else if ( strict_owner && owner !=active_thread() ) {119 } else if ( strict_owner && active_thread() ) { 118 120 fprintf( stderr, "A thread other than the owner attempted to release an owner lock" ); 119 121 return; … … 125 127 recursion_count = ( thrd && multi_acquisition ? 1 : 0 ); 126 128 wait_count--; 127 unpark( thrd __cfaabi_dbg_ctx2);129 unpark( thrd ); 128 130 } 129 131 unlock( lock ); … … 152 154 owner = t; 153 155 if ( multi_acquisition ) recursion_count = 1; 154 unpark( t __cfaabi_dbg_ctx2 ); 156 #if !defined( __CFA_NO_STATISTICS__ ) 157 kernelTLS.this_stats = t->curr_cluster->stats; 158 #endif 159 unpark( t ); 155 160 unlock( lock ); 156 161 } … … 161 166 if ( owner == 0p ){ // no owner implies lock isn't held 162 167 fprintf( stderr, "A lock that is not held was passed to a synchronization lock" ); 163 } else if ( strict_owner && owner !=active_thread() ) {168 } else if ( strict_owner && active_thread() ) { 164 169 fprintf( stderr, "A thread other than the owner of a lock passed it to a synchronization lock" ); 165 170 } else { … … 168 173 recursion_count = ( thrd && multi_acquisition ? 1 : 0 ); 169 174 wait_count--; 170 unpark( thrd __cfaabi_dbg_ctx2);175 unpark( thrd ); 171 176 } 172 177 unlock( lock ); … … 177 182 /////////////////////////////////////////////////////////////////// 178 183 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 184 // This is temporary until an inheritance bug is fixed 182 185 183 186 void lock( mutex_lock & this ){ … … 230 233 231 234 /////////////////////////////////////////////////////////////////// 232 //// Synchronization Locks235 //// condition variable 233 236 /////////////////////////////////////////////////////////////////// 234 237 235 238 forall(dtype L | is_blocking_lock(L)) { 236 void ?{}( synchronization_lock(L) & this, bool reacquire_after_signal ){ 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 ){ 237 266 this.lock{}; 238 267 this.blocked_threads{}; 239 268 this.count = 0; 240 this.reacquire_after_signal = reacquire_after_signal;241 }242 243 void ^?{}( synchronization_lock(L) & this ){244 // default245 }246 247 void ?{}( condition_variable(L) & this ){248 ((synchronization_lock(L) &)this){ true };249 269 } 250 270 … … 253 273 } 254 274 255 void ?{}( thread_queue(L) & this ){256 ((synchronization_lock(L) &)this){ false};257 } 258 259 void ^?{}( thread_queue(L) & this ){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 ) { 260 280 // default 261 281 } 262 282 263 bool notify_one( synchronization_lock(L) & this ) with( this ) {283 bool notify_one( condition_variable(L) & this ) with( this ) { 264 284 lock( lock __cfaabi_dbg_ctx2 ); 265 285 bool ret = !!blocked_threads; 266 286 info_thread(L) * popped = pop_head( blocked_threads ); 287 popped->listed = false; 267 288 if(popped != 0p) { 268 if( reacquire_after_signal ){ 289 count--; 290 if (popped->lock) { 269 291 add_(*popped->lock, popped->t); 270 292 } else { 271 unpark( 272 popped->t __cfaabi_dbg_ctx2 273 ); 293 unpark(popped->t); 274 294 } 275 295 } … … 278 298 } 279 299 280 bool notify_all( synchronization_lock(L) & this ) with(this) {300 bool notify_all( condition_variable(L) & this ) with(this) { 281 301 lock( lock __cfaabi_dbg_ctx2 ); 282 302 bool ret = blocked_threads ? true : false; 283 303 while( blocked_threads ) { 284 304 info_thread(L) * popped = pop_head( blocked_threads ); 305 popped->listed = false; 285 306 if(popped != 0p){ 286 if( reacquire_after_signal ){ 307 count--; 308 if (popped->lock) { 287 309 add_(*popped->lock, popped->t); 288 310 } else { 289 unpark( 290 popped->t __cfaabi_dbg_ctx2 291 ); 311 unpark(popped->t); 292 312 } 293 313 } … … 297 317 } 298 318 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) { 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) { 304 325 return blocked_threads ? false : true; 305 326 } 306 327 307 int counter( synchronization_lock(L) & this ) with(this) {328 int counter( condition_variable(L) & this ) with(this) { 308 329 return count; 309 330 } 310 331 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) { 332 // helper for wait()'s' without a timeout 333 void queue_info_thread( condition_variable(L) & this, info_thread(L) & i ) with(this) { 351 334 lock( lock __cfaabi_dbg_ctx2 ); 352 335 append( this.blocked_threads, &i ); 353 336 count++; 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) { 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) { 364 409 info_thread(L) i = { active_thread() }; 365 queue_info_thread_unlock( this, l, i ); 366 } 367 368 void wait( synchronization_lock(L) & this, L & l, uintptr_t info ) with(this) { 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) { 369 415 info_thread(L) i = { active_thread(), info }; 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 } 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 } -
TabularUnified libcfa/src/concurrency/locks.hfa ¶
rbe73f30 r3959595 1 #pragma once 2 1 3 #include <stdbool.h> 2 4 … … 10 12 #include "time.hfa" 11 13 #include <sys/time.h> 14 #include "alarm.hfa" 12 15 13 16 /////////////////////////////////////////////////////////////////// … … 32 35 info_thread(L) * next; 33 36 L * lock; 37 bool listed; // true if info_thread is on queue, false otherwise; 34 38 }; 35 39 … … 119 123 /////////////////////////////////////////////////////////////////// 120 124 forall(dtype L | is_blocking_lock(L)) { 121 struct synchronization_lock{125 struct condition_variable { 122 126 // Spin lock used for mutual exclusion 123 127 __spinlock_t lock; … … 128 132 // Count of current blocked threads 129 133 int count; 130 131 // If true threads will reacquire the lock they block on upon waking132 bool reacquire_after_signal;133 134 }; 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 );146 135 147 136 void ?{}( condition_variable(L) & this ); 148 137 void ^?{}( condition_variable(L) & this ); 149 138 150 void ?{}( thread_queue(L) & this );151 void ^?{}( thread_queue(L) & this );139 struct alarm_node_wrap { 140 alarm_node_t alarm_node; 152 141 153 bool notify_one( synchronization_lock(L) & this ); 154 bool notify_all( synchronization_lock(L) & this ); 142 condition_variable(L) * cond; 155 143 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 ); 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; 144 info_thread(L) ** i; 203 145 }; 204 146 205 void ?{}( condition_lock(L) & this);206 void ^?{}( condition_lock(L) & this );147 void ?{}( alarm_node_wrap(L) & this, $thread * thrd, Time alarm, Duration period, Alarm_Callback callback ); 148 void ^?{}( alarm_node_wrap(L) & this ); 207 149 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 ); 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 ); 211 176 } -
TabularUnified libcfa/src/concurrency/preemption.cfa ¶
rbe73f30 r3959595 105 105 106 106 // Check if this is a kernel 107 if( node-> kernel_alarm) {107 if( node->type == Kernel ) { 108 108 preempt( node->proc ); 109 109 } 110 else if( node->type == User ) { 111 timeout( node->thrd ); 112 } 110 113 else { 111 timeout( node->thrd);114 node->callback(*node); 112 115 } 113 116 -
TabularUnified src/InitTweak/FixGlobalInit.cc ¶
rbe73f30 r3959595 183 183 } // if 184 184 if ( const ast::Stmt * ctor = ctorInit->ctor ) { 185 addDataSectionAttribute(mutDecl); 185 186 initStmts.push_back( ctor ); 186 187 mutDecl->init = nullptr; -
TabularUnified src/InitTweak/FixInitNew.cpp ¶
rbe73f30 r3959595 864 864 if ( const ast::Stmt * ctor = ctorInit->ctor ) { 865 865 if ( objDecl->storage.is_static ) { 866 addDataSectionAttribute(objDecl); 866 867 // originally wanted to take advantage of gcc nested functions, but 867 868 // we get memory errors with this approach. To remedy this, the static … … 947 948 objDecl->name = objDecl->name + staticNamer.newName(); 948 949 objDecl->mangleName = Mangle::mangle( objDecl ); 950 objDecl->init = nullptr; 949 951 950 952 // xxx - temporary hack: need to return a declaration, but want to hoist the current object out of this scope -
TabularUnified src/InitTweak/InitTweak.cc ¶
rbe73f30 r3959595 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 1115 1120 } -
TabularUnified src/InitTweak/InitTweak.h ¶
rbe73f30 r3959595 119 119 void addDataSectonAttribute( ObjectDecl * objDecl ); 120 120 121 void addDataSectionAttribute( ast::ObjectDecl * objDecl ); 122 121 123 class InitExpander_old { 122 124 public:
Note: See TracChangeset
for help on using the changeset viewer.