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.
This commit is contained in:
Joel Sherrill
2009-07-09 21:55:23 +00:00
parent 7f8dd5758e
commit b503e0b92e
2 changed files with 51 additions and 47 deletions

View File

@@ -1,3 +1,8 @@
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> 2009-07-09 Joel Sherrill <joel.sherrill@OARcorp.com>
* score/src/heap.c: Remove unneeded include. * score/src/heap.c: Remove unneeded include.

View File

@@ -82,7 +82,6 @@ rtems_status_code rtems_semaphore_create(
CORE_semaphore_Attributes the_semaphore_attr; CORE_semaphore_Attributes the_semaphore_attr;
CORE_mutex_Status mutex_status; CORE_mutex_Status mutex_status;
if ( !rtems_is_name_valid( name ) ) if ( !rtems_is_name_valid( name ) )
return RTEMS_INVALID_NAME; return RTEMS_INVALID_NAME;
@@ -95,7 +94,8 @@ rtems_status_code rtems_semaphore_create(
if ( !_System_state_Is_multiprocessing ) if ( !_System_state_Is_multiprocessing )
return RTEMS_MP_NOT_CONFIGURED; 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; return RTEMS_NOT_DEFINED;
} else } else
@@ -104,9 +104,7 @@ rtems_status_code rtems_semaphore_create(
if ( _Attributes_Is_inherit_priority( attribute_set ) || if ( _Attributes_Is_inherit_priority( attribute_set ) ||
_Attributes_Is_priority_ceiling( attribute_set ) ) { _Attributes_Is_priority_ceiling( attribute_set ) ) {
if ( ! ( (_Attributes_Is_binary_semaphore( attribute_set ) || if ( ! (_Attributes_Is_binary_semaphore( attribute_set ) &&
_Attributes_Is_simple_binary_semaphore( attribute_set )) &&
_Attributes_Is_priority( attribute_set ) ) ) _Attributes_Is_priority( attribute_set ) ) )
return RTEMS_NOT_DEFINED; return RTEMS_NOT_DEFINED;
@@ -165,14 +163,11 @@ rtems_status_code rtems_semaphore_create(
&the_semaphore_attr, &the_semaphore_attr,
count count
); );
goto open_object; } else {
}
/* /*
* It is either simple binary semaphore or a more powerful mutex * It is either simple binary semaphore or a more powerful mutex
* style binary semaphore. This is the mutex style. * style binary semaphore. This is the mutex style.
*/ */
if ( _Attributes_Is_priority( attribute_set ) ) if ( _Attributes_Is_priority( attribute_set ) )
the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY; the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY;
else else
@@ -181,17 +176,17 @@ rtems_status_code rtems_semaphore_create(
if ( _Attributes_Is_binary_semaphore( attribute_set ) ) { if ( _Attributes_Is_binary_semaphore( attribute_set ) ) {
the_mutex_attr.priority_ceiling = priority_ceiling; the_mutex_attr.priority_ceiling = priority_ceiling;
the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_ACQUIRES; 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 ( the_mutex_attr.discipline == CORE_MUTEX_DISCIPLINES_PRIORITY ) {
if ( _Attributes_Is_inherit_priority( attribute_set ) ) { if ( _Attributes_Is_inherit_priority( attribute_set ) ) {
the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT;
the_mutex_attr.only_owner_release = true; the_mutex_attr.only_owner_release = true;
} else { } else if ( _Attributes_Is_priority_ceiling( attribute_set ) ) {
the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; the_mutex_attr.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING;
the_mutex_attr.only_owner_release = true; the_mutex_attr.only_owner_release = true;
} }
} else }
the_mutex_attr.only_owner_release = false;
} else /* must be simple binary semaphore */ { } else /* must be simple binary semaphore */ {
the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_BLOCKS; the_mutex_attr.lock_nesting_behavior = CORE_MUTEX_NESTING_BLOCKS;
the_mutex_attr.only_owner_release = false; the_mutex_attr.only_owner_release = false;
@@ -208,8 +203,12 @@ rtems_status_code rtems_semaphore_create(
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
return RTEMS_INVALID_PRIORITY; 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( _Objects_Open(
&_Semaphore_Information, &_Semaphore_Information,
&the_semaphore->Object, &the_semaphore->Object,