diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-09 21:55:23 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-09 21:55:23 +0000 |
commit | b503e0b92eb02b0a76bf6ae1c7cc955d6fd0f4c2 (patch) | |
tree | 7e452242a469d42b0ff1f829f25fb0772536cef9 /cpukit | |
parent | 2009-07-09 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-b503e0b92eb02b0a76bf6ae1c7cc955d6fd0f4c2.tar.bz2 |
2009-07-09 Joel Sherrill <joel.sherrill@OARcorp.com>
* rtems/src/semcreate.c: Clean up rework to eliminate the goto and fix
a bug introduced by rework.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/ChangeLog | 5 | ||||
-rw-r--r-- | cpukit/rtems/src/semcreate.c | 93 |
2 files changed, 51 insertions, 47 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index dda2da2167..4a0da5eace 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,5 +1,10 @@ 2009-07-09 Joel Sherrill <joel.sherrill@OARcorp.com> + * rtems/src/semcreate.c: Clean up rework to eliminate the goto and fix + a bug introduced by rework. + +2009-07-09 Joel Sherrill <joel.sherrill@OARcorp.com> + * score/src/heap.c: Remove unneeded include. 2009-07-08 Joel Sherrill <joel.sherrill@OARcorp.com> diff --git a/cpukit/rtems/src/semcreate.c b/cpukit/rtems/src/semcreate.c index a0ce7ecdda..85d1c15bc9 100644 --- a/cpukit/rtems/src/semcreate.c +++ b/cpukit/rtems/src/semcreate.c @@ -82,7 +82,6 @@ rtems_status_code rtems_semaphore_create( CORE_semaphore_Attributes the_semaphore_attr; CORE_mutex_Status mutex_status; - if ( !rtems_is_name_valid( name ) ) return RTEMS_INVALID_NAME; @@ -95,7 +94,8 @@ rtems_status_code rtems_semaphore_create( if ( !_System_state_Is_multiprocessing ) return RTEMS_MP_NOT_CONFIGURED; - if ( _Attributes_Is_inherit_priority( attribute_set ) ) + if ( _Attributes_Is_inherit_priority( attribute_set ) || + _Attributes_Is_priority_ceiling( attribute_set ) ) { return RTEMS_NOT_DEFINED; } else @@ -104,10 +104,8 @@ rtems_status_code rtems_semaphore_create( if ( _Attributes_Is_inherit_priority( attribute_set ) || _Attributes_Is_priority_ceiling( attribute_set ) ) { - if ( ! ( (_Attributes_Is_binary_semaphore( attribute_set ) || - _Attributes_Is_simple_binary_semaphore( attribute_set )) && - - _Attributes_Is_priority( attribute_set ) ) ) + if ( ! (_Attributes_Is_binary_semaphore( attribute_set ) && + _Attributes_Is_priority( attribute_set ) ) ) return RTEMS_NOT_DEFINED; } @@ -165,51 +163,52 @@ rtems_status_code rtems_semaphore_create( &the_semaphore_attr, count ); - goto open_object; - } - - /* - * It is either simple binary semaphore or a more powerful mutex - * style binary semaphore. This is the mutex style. - */ - - if ( _Attributes_Is_priority( attribute_set ) ) - the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY; - else - the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_FIFO; - - if ( _Attributes_Is_binary_semaphore( attribute_set ) ) { - the_mutex_attr.priority_ceiling = priority_ceiling; - the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES; - - if ( the_mutex_attr.discipline == CORE_MUTEX_DISCIPLINES_PRIORITY ) { - if ( _Attributes_Is_inherit_priority( attribute_set ) ) { - the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; - the_mutex_attr.only_owner_release = true; - } else { - the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; - the_mutex_attr.only_owner_release = true; + } else { + /* + * It is either simple binary semaphore or a more powerful mutex + * style binary semaphore. This is the mutex style. + */ + if ( _Attributes_Is_priority( attribute_set ) ) + the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY; + else + the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_FIFO; + + if ( _Attributes_Is_binary_semaphore( attribute_set ) ) { + the_mutex_attr.priority_ceiling = priority_ceiling; + the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES; + the_mutex_attr.only_owner_release = false; + + if ( the_mutex_attr.discipline == CORE_MUTEX_DISCIPLINES_PRIORITY ) { + if ( _Attributes_Is_inherit_priority( attribute_set ) ) { + the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; + the_mutex_attr.only_owner_release = true; + } else if ( _Attributes_Is_priority_ceiling( attribute_set ) ) { + the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; + the_mutex_attr.only_owner_release = true; + } } - } else + } else /* must be simple binary semaphore */ { + the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_BLOCKS; the_mutex_attr.only_owner_release = false; - } else /* must be simple binary semaphore */ { - the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_BLOCKS; - the_mutex_attr.only_owner_release = false; - } - - mutex_status = _CORE_mutex_Initialize( - &the_semaphore->Core_control.mutex, - &the_mutex_attr, - (count == 1) ? CORE_MUTEX_UNLOCKED : CORE_MUTEX_LOCKED - ); - - if ( mutex_status == CORE_MUTEX_STATUS_CEILING_VIOLATED ) { - _Semaphore_Free( the_semaphore ); - _Thread_Enable_dispatch(); - return RTEMS_INVALID_PRIORITY; + } + + mutex_status = _CORE_mutex_Initialize( + &the_semaphore->Core_control.mutex, + &the_mutex_attr, + (count == 1) ? CORE_MUTEX_UNLOCKED : CORE_MUTEX_LOCKED + ); + + if ( mutex_status == CORE_MUTEX_STATUS_CEILING_VIOLATED ) { + _Semaphore_Free( the_semaphore ); + _Thread_Enable_dispatch(); + return RTEMS_INVALID_PRIORITY; + } } -open_object: + /* + * Whether we initialized it as a mutex or counting semaphore, it is + * now ready to be "offered" for use as a Classic API Semaphore. + */ _Objects_Open( &_Semaphore_Information, &the_semaphore->Object, |