comparison packages/kernel/current/include/thread.inl @ 210:d2c90368aeef

Merge from eCos master repository on 2002-05-23-21:39:14-BST
author jlarmour
date Thu, 23 May 2002 22:59:51 +0000
parents e0c0827131d1
children 52f0600c2119
comparison
equal deleted inserted replaced
209:19edcb2e78cc 210:d2c90368aeef
35 // 35 //
36 // This exception does not invalidate any other reasons why a work based on 36 // This exception does not invalidate any other reasons why a work based on
37 // this file might be covered by the GNU General Public License. 37 // this file might be covered by the GNU General Public License.
38 // 38 //
39 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. 39 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40 // at http://sources.redhat.com/ecos/ecos-license 40 // at http://sources.redhat.com/ecos/ecos-license/
41 // ------------------------------------------- 41 // -------------------------------------------
42 //####ECOSGPLCOPYRIGHTEND#### 42 //####ECOSGPLCOPYRIGHTEND####
43 //========================================================================== 43 //==========================================================================
44 //#####DESCRIPTIONBEGIN#### 44 //#####DESCRIPTIONBEGIN####
45 // 45 //
502 502
503 // ------------------------------------------------------------------------- 503 // -------------------------------------------------------------------------
504 504
505 #ifdef CYGPKG_KERNEL_THREADS_DESTRUCTORS 505 #ifdef CYGPKG_KERNEL_THREADS_DESTRUCTORS
506 506
507 // Add and remove destructors. Returns true on success, false on failure. 507 // Add and remove destructors. Returns true on success, false on failure.
508 inline cyg_bool 508 inline cyg_bool
509 Cyg_Thread::add_destructor( destructor_fn fn, CYG_ADDRWORD data ) 509 Cyg_Thread::add_destructor( destructor_fn fn, CYG_ADDRWORD data )
510 { 510 {
511 cyg_ucount16 i; 511 cyg_ucount16 i;
512 #ifndef CYGSEM_KERNEL_THREADS_DESTRUCTORS_PER_THREAD
512 Cyg_Scheduler::lock(); 513 Cyg_Scheduler::lock();
514 #endif
513 for (i=0; i<CYGNUM_KERNEL_THREADS_DESTRUCTORS; i++) { 515 for (i=0; i<CYGNUM_KERNEL_THREADS_DESTRUCTORS; i++) {
514 if (NULL == destructors[i].fn) { 516 if (NULL == destructors[i].fn) {
515 destructors[i].data = data; 517 destructors[i].data = data;
516 destructors[i].fn = fn; 518 destructors[i].fn = fn;
519 #ifndef CYGSEM_KERNEL_THREADS_DESTRUCTORS_PER_THREAD
517 Cyg_Scheduler::unlock(); 520 Cyg_Scheduler::unlock();
521 #endif
518 return true; 522 return true;
519 } 523 }
520 } 524 }
525 #ifndef CYGSEM_KERNEL_THREADS_DESTRUCTORS_PER_THREAD
521 Cyg_Scheduler::unlock(); 526 Cyg_Scheduler::unlock();
527 #endif
522 return false; 528 return false;
523 } 529 }
524 530
525 inline cyg_bool 531 inline cyg_bool
526 Cyg_Thread::rem_destructor( destructor_fn fn, CYG_ADDRWORD data ) 532 Cyg_Thread::rem_destructor( destructor_fn fn, CYG_ADDRWORD data )
527 { 533 {
528 cyg_ucount16 i; 534 cyg_ucount16 i;
535 #ifndef CYGSEM_KERNEL_THREADS_DESTRUCTORS_PER_THREAD
529 Cyg_Scheduler::lock(); 536 Cyg_Scheduler::lock();
537 #endif
530 for (i=0; i<CYGNUM_KERNEL_THREADS_DESTRUCTORS; i++) { 538 for (i=0; i<CYGNUM_KERNEL_THREADS_DESTRUCTORS; i++) {
531 if (destructors[i].fn == fn && destructors[i].data == data) { 539 if (destructors[i].fn == fn && destructors[i].data == data) {
532 destructors[i].fn = NULL; 540 destructors[i].fn = NULL;
541 #ifndef CYGSEM_KERNEL_THREADS_DESTRUCTORS_PER_THREAD
533 Cyg_Scheduler::unlock(); 542 Cyg_Scheduler::unlock();
543 #endif
534 return true; 544 return true;
535 } 545 }
536 } 546 }
547 #ifndef CYGSEM_KERNEL_THREADS_DESTRUCTORS_PER_THREAD
537 Cyg_Scheduler::unlock(); 548 Cyg_Scheduler::unlock();
549 #endif
538 return false; 550 return false;
539 } 551 }
540
541 #endif 552 #endif
542 553
543 // ------------------------------------------------------------------------- 554 // -------------------------------------------------------------------------
544 555
545 #ifdef CYGVAR_KERNEL_THREADS_NAME 556 #ifdef CYGVAR_KERNEL_THREADS_NAME