forked from Imagelibrary/rtems
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:
@@ -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>
|
||||
|
||||
* score/src/heap.c: Remove unneeded include.
|
||||
|
||||
@@ -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,9 +104,7 @@ 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 )) &&
|
||||
|
||||
if ( ! (_Attributes_Is_binary_semaphore( attribute_set ) &&
|
||||
_Attributes_Is_priority( attribute_set ) ) )
|
||||
return RTEMS_NOT_DEFINED;
|
||||
|
||||
@@ -165,14 +163,11 @@ rtems_status_code rtems_semaphore_create(
|
||||
&the_semaphore_attr,
|
||||
count
|
||||
);
|
||||
goto open_object;
|
||||
}
|
||||
|
||||
} 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
|
||||
@@ -181,17 +176,17 @@ rtems_status_code rtems_semaphore_create(
|
||||
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 {
|
||||
} 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
|
||||
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;
|
||||
@@ -208,8 +203,12 @@ rtems_status_code rtems_semaphore_create(
|
||||
_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,
|
||||
|
||||
Reference in New Issue
Block a user