summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/include/rtems/rtems/regionimpl.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-08 06:56:46 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-12 07:36:19 +0200
commit1142f5593a5b6ab65d47bafb749e0709c7d2daa2 (patch)
tree44d5b886a880307bd6f38550a7275071f38965a7 /cpukit/rtems/include/rtems/rtems/regionimpl.h
parentscore: Simplify _Objects_Get_no_protection() (diff)
downloadrtems-1142f5593a5b6ab65d47bafb749e0709c7d2daa2.tar.bz2
rtems: Add and use _Region_Get_and_lock()
Get region and lock allocator in _Region_Get_and_lock() in case the region exists and unlock it in _Region_Unlock().
Diffstat (limited to 'cpukit/rtems/include/rtems/rtems/regionimpl.h')
-rw-r--r--cpukit/rtems/include/rtems/rtems/regionimpl.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/regionimpl.h b/cpukit/rtems/include/rtems/rtems/regionimpl.h
index 60cf50c2fd..4db65997a7 100644
--- a/cpukit/rtems/include/rtems/rtems/regionimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/regionimpl.h
@@ -19,7 +19,6 @@
#include <rtems/rtems/region.h>
#include <rtems/score/apimutex.h>
-#include <rtems/score/assert.h>
#include <rtems/score/heapimpl.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/threadqimpl.h>
@@ -67,11 +66,28 @@ RTEMS_INLINE_ROUTINE void _Region_Free (
_Objects_Free( &_Region_Information, &the_region->Object );
}
-RTEMS_INLINE_ROUTINE Region_Control *_Region_Get( Objects_Id id )
+RTEMS_INLINE_ROUTINE Region_Control *_Region_Get_and_lock( Objects_Id id )
{
- _Assert( _RTEMS_Allocator_is_owner() );
- return (Region_Control *)
+ Region_Control *the_region;
+
+ _RTEMS_Lock_allocator();
+
+ the_region = (Region_Control *)
_Objects_Get_no_protection( &_Region_Information, id );
+
+ if ( the_region != NULL ) {
+ /* Keep allocator lock */
+ return the_region;
+ }
+
+ _RTEMS_Unlock_allocator();
+ return NULL;
+}
+
+RTEMS_INLINE_ROUTINE void _Region_Unlock( Region_Control *the_region )
+{
+ (void) the_region;
+ _RTEMS_Unlock_allocator();
}
/**