diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 78e39e1044..cb6d002875 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,8 @@ +2008-01-29 Jennifer Averett + + * score/src/corerwlockrelease.c, score/src/coresemseize.c: Changed + switch statements to if statements. + 2008-01-29 Joel Sherrill * libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h, diff --git a/cpukit/score/src/corerwlockrelease.c b/cpukit/score/src/corerwlockrelease.c index 4d29cd0f21..98aa973580 100644 --- a/cpukit/score/src/corerwlockrelease.c +++ b/cpukit/score/src/corerwlockrelease.c @@ -49,59 +49,57 @@ CORE_RWLock_Status _CORE_RWLock_Release( */ _ISR_Disable( level ); - switch ( the_rwlock->current_state ) { - case CORE_RWLOCK_UNLOCKED: - _ISR_Enable( level ); - executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE; - return CORE_RWLOCK_SUCCESSFUL; - - case CORE_RWLOCK_LOCKED_FOR_READING: + if ( the_rwlock->current_state == CORE_RWLOCK_UNLOCKED){ + _ISR_Enable( level ); + executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE; + return CORE_RWLOCK_SUCCESSFUL; + } + if ( the_rwlock->current_state == CORE_RWLOCK_LOCKED_FOR_READING ) { the_rwlock->number_of_readers -= 1; if ( the_rwlock->number_of_readers != 0 ) { /* must be unlocked again */ _ISR_Enable( level ); return CORE_RWLOCK_SUCCESSFUL; } - executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; - break; - case CORE_RWLOCK_LOCKED_FOR_WRITING: - executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; - break; - } + } + + /* CORE_RWLOCK_LOCKED_FOR_WRITING or READING with readers */ + executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; /* * Implicitly transition to "unlocked" and find another thread interested * in obtaining this rwlock. */ the_rwlock->current_state = CORE_RWLOCK_UNLOCKED; - _ISR_Enable( level ); + _ISR_Enable( level ); - next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue ); + next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue ); - if ( next ) { - if ( next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) { - the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING; - return CORE_RWLOCK_SUCCESSFUL; - } - - /* - * Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING - */ - the_rwlock->number_of_readers += 1; - the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_READING; - - /* - * Now see if more readers can be let go. - */ - while ( 1 ) { - next = _Thread_queue_First( &the_rwlock->Wait_queue ); - if ( !next || - next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) - return CORE_RWLOCK_SUCCESSFUL; - the_rwlock->number_of_readers += 1; - _Thread_queue_Extract( &the_rwlock->Wait_queue, next ); - } + if ( next ) { + if ( next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) { + the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING; + return CORE_RWLOCK_SUCCESSFUL; } + + /* + * Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING + */ + the_rwlock->number_of_readers += 1; + the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_READING; + + /* + * Now see if more readers can be let go. + */ + while ( 1 ) { + next = _Thread_queue_First( &the_rwlock->Wait_queue ); + if ( !next || + next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) + return CORE_RWLOCK_SUCCESSFUL; + the_rwlock->number_of_readers += 1; + _Thread_queue_Extract( &the_rwlock->Wait_queue, next ); + } + } + /* indentation is to match _ISR_Disable at top */ return CORE_RWLOCK_SUCCESSFUL; diff --git a/cpukit/score/src/coresemseize.c b/cpukit/score/src/coresemseize.c index 693a19a713..71b8a26c8b 100644 --- a/cpukit/score/src/coresemseize.c +++ b/cpukit/score/src/coresemseize.c @@ -69,23 +69,23 @@ void _CORE_semaphore_Seize( return; } - switch ( wait ) { - case CORE_SEMAPHORE_NO_WAIT: + if ( wait == CORE_SEMAPHORE_NO_WAIT ) { _ISR_Enable( level ); executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT; return; - case CORE_SEMAPHORE_BAD_TIMEOUT: + } + if (wait == CORE_SEMAPHORE_BAD_TIMEOUT ) { _ISR_Enable( level ); executing->Wait.return_code = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE; return; - case CORE_SEMAPHORE_BLOCK_FOREVER: - case CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT: + } + if (( wait == CORE_SEMAPHORE_BLOCK_FOREVER) || + ( wait == CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT ) ) { _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue ); executing->Wait.queue = &the_semaphore->Wait_queue; executing->Wait.id = id; _ISR_Enable( level ); _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout ); - break; } }