From 0e8656b49eecdff64d639e765ef861cd974392e9 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 19 Jul 2013 14:39:45 +0200 Subject: posix: Create rwlock implementation header Move implementation specific parts of rwlock.h and rwlock.inl into new header file rwlockimpl.h. The rwlock.h contains now only the application visible API. --- cpukit/libcsupport/src/resource_snapshot.c | 2 +- cpukit/posix/Makefile.am | 2 +- cpukit/posix/include/rtems/posix/rwlock.h | 48 +-------- cpukit/posix/include/rtems/posix/rwlockimpl.h | 140 ++++++++++++++++++++++++++ cpukit/posix/inline/rtems/posix/rwlock.inl | 96 ------------------ cpukit/posix/preinstall.am | 8 +- cpukit/posix/src/prwlock.c | 2 +- cpukit/posix/src/prwlockdestroy.c | 2 +- cpukit/posix/src/prwlockinit.c | 2 +- cpukit/posix/src/prwlockrdlock.c | 2 +- cpukit/posix/src/prwlocktimedrdlock.c | 2 +- cpukit/posix/src/prwlocktimedwrlock.c | 2 +- cpukit/posix/src/prwlocktranslatereturncode.c | 2 +- cpukit/posix/src/prwlocktryrdlock.c | 2 +- cpukit/posix/src/prwlocktrywrlock.c | 2 +- cpukit/posix/src/prwlockunlock.c | 2 +- cpukit/posix/src/prwlockwrlock.c | 2 +- cpukit/sapi/src/posixapi.c | 2 +- 18 files changed, 161 insertions(+), 159 deletions(-) create mode 100644 cpukit/posix/include/rtems/posix/rwlockimpl.h delete mode 100644 cpukit/posix/inline/rtems/posix/rwlock.inl (limited to 'cpukit') diff --git a/cpukit/libcsupport/src/resource_snapshot.c b/cpukit/libcsupport/src/resource_snapshot.c index d3f162ff05..6b875a8487 100644 --- a/cpukit/libcsupport/src/resource_snapshot.c +++ b/cpukit/libcsupport/src/resource_snapshot.c @@ -37,7 +37,7 @@ #include #include #include - #include + #include #include #include #include diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am index f378209ee7..6e69fdd6bd 100644 --- a/cpukit/posix/Makefile.am +++ b/cpukit/posix/Makefile.am @@ -49,11 +49,11 @@ include_rtems_posix_HEADERS += include/rtems/posix/timer.h include_rtems_posix_HEADERS += include/rtems/posix/barrier.h include_rtems_posix_HEADERS += include/rtems/posix/barrierimpl.h include_rtems_posix_HEADERS += include/rtems/posix/rwlock.h +include_rtems_posix_HEADERS += include/rtems/posix/rwlockimpl.h include_rtems_posix_HEADERS += include/rtems/posix/spinlock.h include_rtems_posix_HEADERS += inline/rtems/posix/key.inl include_rtems_posix_HEADERS += inline/rtems/posix/timer.inl -include_rtems_posix_HEADERS += inline/rtems/posix/rwlock.inl include_rtems_posix_HEADERS += inline/rtems/posix/spinlock.inl ## src diff --git a/cpukit/posix/include/rtems/posix/rwlock.h b/cpukit/posix/include/rtems/posix/rwlock.h index 0cfd20dad8..31f75c2d58 100644 --- a/cpukit/posix/include/rtems/posix/rwlock.h +++ b/cpukit/posix/include/rtems/posix/rwlock.h @@ -25,6 +25,9 @@ #ifndef _RTEMS_POSIX_RWLOCK_H #define _RTEMS_POSIX_RWLOCK_H +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -39,9 +42,6 @@ extern "C" { */ /**@{**/ -#include -#include - /** * This type defines the control block used to manage each RWLock. */ @@ -53,48 +53,6 @@ typedef struct { CORE_RWLock_Control RWLock; } POSIX_RWLock_Control; -/** - * The following defines the information control block used to manage - * this class of objects. - */ - -POSIX_EXTERN Objects_Information _POSIX_RWLock_Information; - -/** - * @brief POSIX RWLock manager initialization. - * - * This routine performs the initialization necessary for this manager. - */ - -void _POSIX_RWLock_Manager_initialization(void); - -/** - * @brief POSIX translate core RWLock return code. - * - * This routine translates SuperCore RWLock status codes into the - * corresponding POSIX ones. - * - * - * @param[in] the_RWLock_status is the SuperCore status. - * - * @return the corresponding POSIX status - * @retval 0 The status indicates that the operation completed successfully. - * @retval EINVAL The status indicates that the thread was blocked waiting for - * an operation to complete and the RWLock was deleted. - * @retval EBUSY This status indicates that the RWLock was not - * immediately available. - * @retval ETIMEDOUT This status indicates that the calling task was - * willing to block but the operation was unable to complete within - * the time allotted because the resource never became available. - */ -int _POSIX_RWLock_Translate_core_RWLock_return_code( - CORE_RWLock_Status the_RWLock_status -); - -#ifndef __RTEMS_APPLICATION__ -#include -#endif - /** @} */ #ifdef __cplusplus diff --git a/cpukit/posix/include/rtems/posix/rwlockimpl.h b/cpukit/posix/include/rtems/posix/rwlockimpl.h new file mode 100644 index 0000000000..5911a8fd41 --- /dev/null +++ b/cpukit/posix/include/rtems/posix/rwlockimpl.h @@ -0,0 +1,140 @@ +/** + * @file + * + * @brief Inlined Routines from the POSIX RWLock Manager + * + * This file contains the static inlin implementation of the inlined + * routines from the POSIX RWLock Manager. + */ + +/* + * 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.com/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_RWLOCKIMPL_H +#define _RTEMS_POSIX_RWLOCKIMPL_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The following defines the information control block used to manage + * this class of objects. + */ + +POSIX_EXTERN Objects_Information _POSIX_RWLock_Information; + +/** + * @brief POSIX RWLock manager initialization. + * + * This routine performs the initialization necessary for this manager. + */ + +void _POSIX_RWLock_Manager_initialization(void); + +/** + * @brief POSIX translate core RWLock return code. + * + * This routine translates SuperCore RWLock status codes into the + * corresponding POSIX ones. + * + * + * @param[in] the_RWLock_status is the SuperCore status. + * + * @return the corresponding POSIX status + * @retval 0 The status indicates that the operation completed successfully. + * @retval EINVAL The status indicates that the thread was blocked waiting for + * an operation to complete and the RWLock was deleted. + * @retval EBUSY This status indicates that the RWLock was not + * immediately available. + * @retval ETIMEDOUT This status indicates that the calling task was + * willing to block but the operation was unable to complete within + * the time allotted because the resource never became available. + */ +int _POSIX_RWLock_Translate_core_RWLock_return_code( + CORE_RWLock_Status the_RWLock_status +); + +/** + * @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 ); +} + +/** + * @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 +) +{ + _Objects_Free( &_POSIX_RWLock_Information, &the_RWLock->Object ); +} + +/** + * @brief Get a RWLock control block. + * + * This function maps RWLock IDs to RWLock control blocks. + * If ID corresponds to a local RWLock, then it returns + * the_RWLock control pointer which maps to ID and location + * is set to OBJECTS_LOCAL. if the RWLock ID is global and + * resides on a remote node, then location is set to OBJECTS_REMOTE, + * and the_RWLock is undefined. Otherwise, location is set + * to OBJECTS_ERROR and the_RWLock is undefined. + */ +RTEMS_INLINE_ROUTINE POSIX_RWLock_Control *_POSIX_RWLock_Get ( + pthread_rwlock_t *RWLock, + Objects_Locations *location +) +{ + return (POSIX_RWLock_Control *) _Objects_Get( + &_POSIX_RWLock_Information, + (Objects_Id) *RWLock, + location + ); +} + +/** + * @brief Check if a RWLock control block is NULL. + * + * This function returns @c TRUE if the_RWLock is @c NULL and @c FALSE + * otherwise. + * + * @param[in] the_RWLock is the pointer to the RWLock control block + * to be checked. + * + * @retval TRUE The RWLock control block is @c NULL. + * @retval FALSE The RWLock control block is not @c NULL. + */ +RTEMS_INLINE_ROUTINE bool _POSIX_RWLock_Is_null ( + POSIX_RWLock_Control *the_RWLock +) +{ + return ( the_RWLock == NULL ); +} + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/posix/inline/rtems/posix/rwlock.inl b/cpukit/posix/inline/rtems/posix/rwlock.inl deleted file mode 100644 index ac641c926b..0000000000 --- a/cpukit/posix/inline/rtems/posix/rwlock.inl +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines from the POSIX RWLock Manager - * - * This file contains the static inlin implementation of the inlined - * routines from the POSIX RWLock Manager. - */ - -/* - * 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.com/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_RWLOCK_H -# error "Never use directly; include instead." -#endif - -#ifndef _RTEMS_POSIX_RWLOCK_INL -#define _RTEMS_POSIX_RWLOCK_INL - -#include - -/** - * @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 ); -} - -/** - * @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 -) -{ - _Objects_Free( &_POSIX_RWLock_Information, &the_RWLock->Object ); -} - -/** - * @brief Get a RWLock control block. - * - * This function maps RWLock IDs to RWLock control blocks. - * If ID corresponds to a local RWLock, then it returns - * the_RWLock control pointer which maps to ID and location - * is set to OBJECTS_LOCAL. if the RWLock ID is global and - * resides on a remote node, then location is set to OBJECTS_REMOTE, - * and the_RWLock is undefined. Otherwise, location is set - * to OBJECTS_ERROR and the_RWLock is undefined. - */ -RTEMS_INLINE_ROUTINE POSIX_RWLock_Control *_POSIX_RWLock_Get ( - pthread_rwlock_t *RWLock, - Objects_Locations *location -) -{ - return (POSIX_RWLock_Control *) _Objects_Get( - &_POSIX_RWLock_Information, - (Objects_Id) *RWLock, - location - ); -} - -/** - * @brief Check if a RWLock control block is NULL. - * - * This function returns @c TRUE if the_RWLock is @c NULL and @c FALSE - * otherwise. - * - * @param[in] the_RWLock is the pointer to the RWLock control block - * to be checked. - * - * @retval TRUE The RWLock control block is @c NULL. - * @retval FALSE The RWLock control block is not @c NULL. - */ -RTEMS_INLINE_ROUTINE bool _POSIX_RWLock_Is_null ( - POSIX_RWLock_Control *the_RWLock -) -{ - return ( the_RWLock == NULL ); -} - -#endif -/* end of include file */ diff --git a/cpukit/posix/preinstall.am b/cpukit/posix/preinstall.am index 2cb926193e..07e987aac2 100644 --- a/cpukit/posix/preinstall.am +++ b/cpukit/posix/preinstall.am @@ -140,6 +140,10 @@ $(PROJECT_INCLUDE)/rtems/posix/rwlock.h: include/rtems/posix/rwlock.h $(PROJECT_ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/rwlock.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/rwlock.h +$(PROJECT_INCLUDE)/rtems/posix/rwlockimpl.h: include/rtems/posix/rwlockimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/rwlockimpl.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/rwlockimpl.h + $(PROJECT_INCLUDE)/rtems/posix/spinlock.h: include/rtems/posix/spinlock.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/spinlock.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/spinlock.h @@ -152,10 +156,6 @@ $(PROJECT_INCLUDE)/rtems/posix/timer.inl: inline/rtems/posix/timer.inl $(PROJECT $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/timer.inl PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/timer.inl -$(PROJECT_INCLUDE)/rtems/posix/rwlock.inl: inline/rtems/posix/rwlock.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/rwlock.inl -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/rwlock.inl - $(PROJECT_INCLUDE)/rtems/posix/spinlock.inl: inline/rtems/posix/spinlock.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/spinlock.inl PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/spinlock.inl diff --git a/cpukit/posix/src/prwlock.c b/cpukit/posix/src/prwlock.c index 1e803cb5ef..c27ca94ce4 100644 --- a/cpukit/posix/src/prwlock.c +++ b/cpukit/posix/src/prwlock.c @@ -17,7 +17,7 @@ #include #include -#include +#include /** * @brief _POSIX_RWLock_Manager_initialization diff --git a/cpukit/posix/src/prwlockdestroy.c b/cpukit/posix/src/prwlockdestroy.c index 329a297f08..a55e985df7 100644 --- a/cpukit/posix/src/prwlockdestroy.c +++ b/cpukit/posix/src/prwlockdestroy.c @@ -21,7 +21,7 @@ #include #include -#include +#include /** * This directive allows a thread to delete a rwlock specified by diff --git a/cpukit/posix/src/prwlockinit.c b/cpukit/posix/src/prwlockinit.c index 0ee53e84d5..a438e5f15a 100644 --- a/cpukit/posix/src/prwlockinit.c +++ b/cpukit/posix/src/prwlockinit.c @@ -24,7 +24,7 @@ #include #include -#include +#include /* * pthread_rwlock_init diff --git a/cpukit/posix/src/prwlockrdlock.c b/cpukit/posix/src/prwlockrdlock.c index 621a7f84a4..3d4d76fab7 100644 --- a/cpukit/posix/src/prwlockrdlock.c +++ b/cpukit/posix/src/prwlockrdlock.c @@ -22,7 +22,7 @@ #include #include -#include +#include /** * This directive attempts to obtain a read only lock on an rwlock instance. diff --git a/cpukit/posix/src/prwlocktimedrdlock.c b/cpukit/posix/src/prwlocktimedrdlock.c index 732ba2a129..29e1c1b4f9 100644 --- a/cpukit/posix/src/prwlocktimedrdlock.c +++ b/cpukit/posix/src/prwlocktimedrdlock.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include /* diff --git a/cpukit/posix/src/prwlocktimedwrlock.c b/cpukit/posix/src/prwlocktimedwrlock.c index bd6232a49a..7a4d76071e 100644 --- a/cpukit/posix/src/prwlocktimedwrlock.c +++ b/cpukit/posix/src/prwlocktimedwrlock.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include /* diff --git a/cpukit/posix/src/prwlocktranslatereturncode.c b/cpukit/posix/src/prwlocktranslatereturncode.c index 48be176d36..72baee340a 100644 --- a/cpukit/posix/src/prwlocktranslatereturncode.c +++ b/cpukit/posix/src/prwlocktranslatereturncode.c @@ -22,7 +22,7 @@ #include #include -#include +#include static int _POSIX_RWLock_Return_codes[CORE_RWLOCK_STATUS_LAST + 1] = { 0, /* CORE_RWLOCK_SUCCESSFUL */ diff --git a/cpukit/posix/src/prwlocktryrdlock.c b/cpukit/posix/src/prwlocktryrdlock.c index c6e2875bb5..c4cfd76108 100644 --- a/cpukit/posix/src/prwlocktryrdlock.c +++ b/cpukit/posix/src/prwlocktryrdlock.c @@ -22,7 +22,7 @@ #include #include -#include +#include /* * pthread_rwlock_tryrdlock diff --git a/cpukit/posix/src/prwlocktrywrlock.c b/cpukit/posix/src/prwlocktrywrlock.c index 26eb3e16bd..23259db34a 100644 --- a/cpukit/posix/src/prwlocktrywrlock.c +++ b/cpukit/posix/src/prwlocktrywrlock.c @@ -22,7 +22,7 @@ #include #include -#include +#include /* * pthread_rwlock_trywrlock diff --git a/cpukit/posix/src/prwlockunlock.c b/cpukit/posix/src/prwlockunlock.c index 67fca021cf..13fc6dcc57 100644 --- a/cpukit/posix/src/prwlockunlock.c +++ b/cpukit/posix/src/prwlockunlock.c @@ -24,7 +24,7 @@ #include #include -#include +#include /* * pthread_rwlock_unlock diff --git a/cpukit/posix/src/prwlockwrlock.c b/cpukit/posix/src/prwlockwrlock.c index 8643be1f4d..b53a7e0a61 100644 --- a/cpukit/posix/src/prwlockwrlock.c +++ b/cpukit/posix/src/prwlockwrlock.c @@ -24,7 +24,7 @@ #include #include -#include +#include /* * pthread_rwlock_wrlock diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c index ba003b6ca7..b460406ce2 100644 --- a/cpukit/sapi/src/posixapi.c +++ b/cpukit/sapi/src/posixapi.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include -- cgit v1.2.3