summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/inline
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2000-07-06 19:33:52 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2000-07-06 19:33:52 +0000
commit3ef54dcc4c0a2366495338b13a8afc055a7f8982 (patch)
tree155a0327b50144499c210915877ae00acbb92068 /cpukit/posix/inline
parentReimplemented _Core_MUTEX_Seize to return with interrupts disabled (diff)
downloadrtems-3ef54dcc4c0a2366495338b13a8afc055a7f8982.tar.bz2
Added support for converting a mutex id to a pointer and returning
with interrupts disabled.
Diffstat (limited to 'cpukit/posix/inline')
-rw-r--r--cpukit/posix/inline/rtems/posix/mutex.inl60
1 files changed, 39 insertions, 21 deletions
diff --git a/cpukit/posix/inline/rtems/posix/mutex.inl b/cpukit/posix/inline/rtems/posix/mutex.inl
index 47ff46d507..b7f5f2e003 100644
--- a/cpukit/posix/inline/rtems/posix/mutex.inl
+++ b/cpukit/posix/inline/rtems/posix/mutex.inl
@@ -41,39 +41,57 @@ RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Free (
/*PAGE
*
* _POSIX_Mutex_Get
+ *
+ * NOTE: The support macro makes it possible for both to use exactly
+ * the same code to check for NULL id pointer and
+ * PTHREAD_MUTEX_INITIALIZER without adding overhead.
*/
+
+#define ___POSIX_Mutex_Get_support( _id, _location ) \
+ do { \
+ int _status; \
+ \
+ if ( !_id ) { \
+ *_location = OBJECTS_ERROR; \
+ return (POSIX_Mutex_Control *) 0; \
+ } \
+ \
+ if ( *_id == PTHREAD_MUTEX_INITIALIZER ) { \
+ /* \
+ * Do an "auto-create" here. \
+ */ \
+ \
+ _status = pthread_mutex_init( _id, 0 ); \
+ if ( _status ) { \
+ *_location = OBJECTS_ERROR; \
+ return (POSIX_Mutex_Control *) 0; \
+ } \
+ } \
+ } while (0)
RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get (
Objects_Id *id,
Objects_Locations *location
)
{
- int status;
-
- if ( !id ) {
- *location = OBJECTS_ERROR;
- return (POSIX_Mutex_Control *) 0;
- }
+ ___POSIX_Mutex_Get_support( id, location );
- if ( *id == PTHREAD_MUTEX_INITIALIZER ) {
- /*
- * Do an "auto-create" here.
- */
-
- status = pthread_mutex_init( id, 0 );
- if ( status ) {
- *location = OBJECTS_ERROR;
- return (POSIX_Mutex_Control *) 0;
- }
- }
+ return (POSIX_Mutex_Control *)
+ _Objects_Get( &_POSIX_Mutex_Information, *id, location );
+}
- /*
- * Now call Objects_Get()
- */
+RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
+ Objects_Id *id,
+ Objects_Locations *location,
+ ISR_Level *level
+)
+{
+ ___POSIX_Mutex_Get_support( id, location );
return (POSIX_Mutex_Control *)
- _Objects_Get( &_POSIX_Mutex_Information, *id, location );
+ _Objects_Get_isr_disable( &_POSIX_Mutex_Information, *id, location, level );
}
+
/*PAGE
*