comparison packages/kernel/current/include/thread.inl @ 182:f62680ef1804

Merge from eCos master repository on 2001-09-07-06:43:02-BST
author jlarmour
date Wed, 12 Sep 2001 00:59:17 +0000
parents 4c750ce71ae3
children 9160a8005d76
comparison
equal deleted inserted replaced
181:d61da071934c 182:f62680ef1804
451 451
452 // ------------------------------------------------------------------------- 452 // -------------------------------------------------------------------------
453 453
454 #ifdef CYGVAR_KERNEL_THREADS_DATA 454 #ifdef CYGVAR_KERNEL_THREADS_DATA
455 455
456 inline CYG_ADDRWORD Cyg_Thread::get_data( cyg_ucount32 index ) 456 inline CYG_ADDRWORD Cyg_Thread::get_data( Cyg_Thread::cyg_data_index index )
457 { 457 {
458 CYG_ASSERT( index < CYGNUM_KERNEL_THREADS_DATA_MAX, 458 CYG_ASSERT( index < CYGNUM_KERNEL_THREADS_DATA_MAX,
459 "Per thread data index out of bounds"); 459 "Per thread data index out of bounds");
460 CYG_ASSERT( (thread_data_map & (1<<index)) == 0, 460 CYG_ASSERT( (thread_data_map & (1<<index)) == 0,
461 "Unallocated index used"); 461 "Unallocated index used");
462 462
463 return self()->thread_data[index]; 463 return self()->thread_data[index];
464 } 464 }
465 465
466 inline CYG_ADDRWORD *Cyg_Thread::get_data_ptr( cyg_ucount32 index ) 466 inline CYG_ADDRWORD *Cyg_Thread::get_data_ptr( Cyg_Thread::cyg_data_index index )
467 { 467 {
468 CYG_ASSERT( index < CYGNUM_KERNEL_THREADS_DATA_MAX, 468 CYG_ASSERT( index < CYGNUM_KERNEL_THREADS_DATA_MAX,
469 "Per thread data index out of bounds"); 469 "Per thread data index out of bounds");
470 CYG_ASSERT( (thread_data_map & (1<<index)) == 0, 470 CYG_ASSERT( (thread_data_map & (1<<index)) == 0,
471 "Unallocated index used"); 471 "Unallocated index used");
472 472
473 return &(self()->thread_data[index]); 473 return &(self()->thread_data[index]);
474 } 474 }
475 475
476 inline void Cyg_Thread::set_data( cyg_ucount32 index, CYG_ADDRWORD data ) 476 inline void Cyg_Thread::set_data( Cyg_Thread::cyg_data_index index,
477 CYG_ADDRWORD data )
477 { 478 {
478 CYG_ASSERT( index < CYGNUM_KERNEL_THREADS_DATA_MAX, 479 CYG_ASSERT( index < CYGNUM_KERNEL_THREADS_DATA_MAX,
479 "Per thread data index out of bounds"); 480 "Per thread data index out of bounds");
480 CYG_ASSERT( (thread_data_map & (1<<index)) == 0, 481 CYG_ASSERT( (thread_data_map & (1<<index)) == 0,
481 "Unallocated index used"); 482 "Unallocated index used");
482 483
483 thread_data[index] = data; 484 thread_data[index] = data;
485 }
486
487 #endif
488
489 // -------------------------------------------------------------------------
490
491 #ifdef CYGPKG_KERNEL_THREADS_DESTRUCTORS
492
493 // Add and remove destructors. Returns true on success, false on failure.
494 inline cyg_bool
495 Cyg_Thread::add_destructor( destructor_fn fn, CYG_ADDRWORD data )
496 {
497 cyg_ucount16 i;
498 Cyg_Scheduler::lock();
499 for (i=0; i<CYGNUM_KERNEL_THREADS_DESTRUCTORS; i++) {
500 if (NULL == destructors[i].fn) {
501 destructors[i].data = data;
502 destructors[i].fn = fn;
503 Cyg_Scheduler::unlock();
504 return true;
505 }
506 }
507 Cyg_Scheduler::unlock();
508 return false;
509 }
510
511 inline cyg_bool
512 Cyg_Thread::rem_destructor( destructor_fn fn, CYG_ADDRWORD data )
513 {
514 cyg_ucount16 i;
515 Cyg_Scheduler::lock();
516 for (i=0; i<CYGNUM_KERNEL_THREADS_DESTRUCTORS; i++) {
517 if (destructors[i].fn == fn && destructors[i].data == data) {
518 destructors[i].fn = NULL;
519 Cyg_Scheduler::unlock();
520 return true;
521 }
522 }
523 Cyg_Scheduler::unlock();
524 return false;
484 } 525 }
485 526
486 #endif 527 #endif
487 528
488 // ------------------------------------------------------------------------- 529 // -------------------------------------------------------------------------