diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-09-21 15:42:45 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-10-05 14:29:02 +0200 |
commit | 89fc9345dea5c675f8d93546fa3c723918d3279a (patch) | |
tree | 89c32d64f375e1a9bf9d3725b1256aeb7ca46221 /cpukit/posix/include/rtems | |
parent | posix: Implement self-contained POSIX barriers (diff) | |
download | rtems-89fc9345dea5c675f8d93546fa3c723918d3279a.tar.bz2 |
posix: Implement self-contained POSIX rwlocks
POSIX rwlocks are now available in all configurations and no longer
depend on --enable-posix.
Update #2514.
Update #3115.
Diffstat (limited to 'cpukit/posix/include/rtems')
-rw-r--r-- | cpukit/posix/include/rtems/posix/config.h | 6 | ||||
-rw-r--r-- | cpukit/posix/include/rtems/posix/rwlock.h | 63 | ||||
-rw-r--r-- | cpukit/posix/include/rtems/posix/rwlockimpl.h | 54 |
3 files changed, 21 insertions, 102 deletions
diff --git a/cpukit/posix/include/rtems/posix/config.h b/cpukit/posix/include/rtems/posix/config.h index dc1ef0c2f1..799eb62f03 100644 --- a/cpukit/posix/include/rtems/posix/config.h +++ b/cpukit/posix/include/rtems/posix/config.h @@ -99,12 +99,6 @@ typedef struct { uint32_t maximum_semaphores; /** - * This field contains the maximum number of POSIX API - * read/write locks which are configured for this application. - */ - uint32_t maximum_rwlocks; - - /** * Maximum configured number of POSIX Shared memory objects. */ uint32_t maximum_shms; diff --git a/cpukit/posix/include/rtems/posix/rwlock.h b/cpukit/posix/include/rtems/posix/rwlock.h deleted file mode 100644 index 3d33d40915..0000000000 --- a/cpukit/posix/include/rtems/posix/rwlock.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file - * - * @brief Constants and Structures Associated with the POSIX RWLock Manager - * - * This include file contains all the constants and structures associated - * with the POSIX RWLock Manager. - * - * Directives provided are: - * - * - create a RWLock - * - delete a RWLock - * - wait for a RWLock - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_RWLOCK_H -#define _RTEMS_POSIX_RWLOCK_H - -#include <rtems/score/object.h> -#include <rtems/score/corerwlock.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup POSIX_RWLOCK POSIX RWLock Manager - * - * @ingroup POSIXAPI - * - * @brief Constants and Structures Associated with the POSIX RWLock Manager - * - */ -/**@{**/ - -/** - * This type defines the control block used to manage each RWLock. - */ - -typedef struct { - /** This is used to manage a RWLock as an object. */ - Objects_Control Object; - /** This is used to implement the RWLock. */ - CORE_RWLock_Control RWLock; -} POSIX_RWLock_Control; - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/rwlockimpl.h b/cpukit/posix/include/rtems/posix/rwlockimpl.h index c355f7dc19..b92ca9d04c 100644 --- a/cpukit/posix/include/rtems/posix/rwlockimpl.h +++ b/cpukit/posix/include/rtems/posix/rwlockimpl.h @@ -19,9 +19,7 @@ #ifndef _RTEMS_POSIX_RWLOCKIMPL_H #define _RTEMS_POSIX_RWLOCKIMPL_H -#include <rtems/posix/rwlock.h> #include <rtems/score/corerwlockimpl.h> -#include <rtems/score/objectimpl.h> #include <errno.h> #include <pthread.h> @@ -30,43 +28,33 @@ extern "C" { #endif -/** - * The following defines the information control block used to manage - * this class of objects. - */ - -extern Objects_Information _POSIX_RWLock_Information; +#define POSIX_RWLOCK_MAGIC 0x9621dabdUL -/** - * @brief Allocate a RWLock control block. - * - * This function allocates a RWLock control block from - * the inactive chain of free RWLock control blocks. - */ -RTEMS_INLINE_ROUTINE POSIX_RWLock_Control *_POSIX_RWLock_Allocate( void ) -{ - return (POSIX_RWLock_Control *) - _Objects_Allocate( &_POSIX_RWLock_Information ); -} +typedef struct { + unsigned long flags; + CORE_RWLock_Control RWLock; +} POSIX_RWLock_Control; -/** - * @brief Free a RWLock control block. - * - * This routine frees a RWLock control block to the - * inactive chain of free RWLock control blocks. - */ -RTEMS_INLINE_ROUTINE void _POSIX_RWLock_Free ( - POSIX_RWLock_Control *the_RWLock +RTEMS_INLINE_ROUTINE POSIX_RWLock_Control *_POSIX_RWLock_Get( + pthread_rwlock_t *rwlock ) { - _CORE_RWLock_Destroy( &the_RWLock->RWLock ); - _Objects_Free( &_POSIX_RWLock_Information, &the_RWLock->Object ); + return (POSIX_RWLock_Control *) rwlock; } -POSIX_RWLock_Control *_POSIX_RWLock_Get( - pthread_rwlock_t *rwlock, - Thread_queue_Context *queue_context -); +bool _POSIX_RWLock_Auto_initialization( POSIX_RWLock_Control *the_rwlock ); + +#define POSIX_RWLOCK_VALIDATE_OBJECT( rw ) \ + do { \ + if ( ( rw ) == NULL ) { \ + return EINVAL; \ + } \ + if ( ( (uintptr_t) ( rw ) ^ POSIX_RWLOCK_MAGIC ) != ( rw )->flags ) { \ + if ( !_POSIX_RWLock_Auto_initialization( rw ) ) { \ + return EINVAL; \ + } \ + } \ + } while ( 0 ) #ifdef __cplusplus } |