Changeset 419accf in rtems
- Timestamp:
- 10/08/14 08:07:01 (9 years ago)
- Branches:
- 4.11, 5, master
- Children:
- dfdad6ab
- Parents:
- 044cf4d7
- git-author:
- Sebastian Huber <sebastian.huber@…> (10/08/14 08:07:01)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (10/08/14 09:26:26)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/posix/src/mutexget.c
r044cf4d7 r419accf 19 19 #endif 20 20 21 #include <errno.h>22 #include <pthread.h>23 24 #include <rtems/system.h>25 #include <rtems/score/coremuteximpl.h>26 21 #include <rtems/posix/muteximpl.h> 27 22 23 static bool _POSIX_Mutex_Check_id_and_auto_init( 24 pthread_mutex_t *mutex, 25 Objects_Locations *location 26 ) 27 { 28 if ( mutex == NULL ) { 29 *location = OBJECTS_ERROR; 28 30 29 /* 30 * _POSIX_Mutex_Get_support 31 * 32 * NOTE: The support macro makes it possible for both to use exactly 33 * the same code to check for NULL id pointer and 34 * PTHREAD_MUTEX_INITIALIZER without adding overhead. 35 */ 31 return false; 32 } 36 33 37 #define ___POSIX_Mutex_Get_support_error_check( _id, _location ) \ 38 do { \ 39 if ( !_id ) { \ 40 *_location = OBJECTS_ERROR; \ 41 return (POSIX_Mutex_Control *) 0; \ 42 } \ 43 } while (0) 34 if ( *mutex == PTHREAD_MUTEX_INITIALIZER ) { 35 int eno; 44 36 45 #define ___POSIX_Mutex_Get_support_auto_initialization( _id, _location ) \ 46 do { \ 47 int _status; \ 48 \ 49 if ( *_id == PTHREAD_MUTEX_INITIALIZER ) { \ 50 /* \ 51 * Do an "auto-create" here. \ 52 */ \ 53 \ 54 _status = pthread_mutex_init( (pthread_mutex_t *)_id, 0 ); \ 55 if ( _status ) { \ 56 *_location = OBJECTS_ERROR; \ 57 return (POSIX_Mutex_Control *) 0; \ 58 } \ 59 } \ 60 } while (0) 37 eno = pthread_mutex_init( mutex, NULL ); 38 39 if ( eno != 0 ) { 40 *location = OBJECTS_ERROR; 41 42 return false; 43 } 44 } 45 46 return true; 47 } 61 48 62 49 POSIX_Mutex_Control *_POSIX_Mutex_Get ( … … 65 52 ) 66 53 { 67 ___POSIX_Mutex_Get_support_error_check( mutex, location );68 69 ___POSIX_Mutex_Get_support_auto_initialization( mutex, location );54 if ( !_POSIX_Mutex_Check_id_and_auto_init( mutex, location ) ) { 55 return NULL; 56 } 70 57 71 58 return (POSIX_Mutex_Control *) … … 79 66 ) 80 67 { 81 ___POSIX_Mutex_Get_support_error_check( mutex, location );82 83 ___POSIX_Mutex_Get_support_auto_initialization( mutex, location );68 if ( !_POSIX_Mutex_Check_id_and_auto_init( mutex, location ) ) { 69 return NULL; 70 } 84 71 85 72 return (POSIX_Mutex_Control *) _Objects_Get_isr_disable(
Note: See TracChangeset
for help on using the changeset viewer.