From c71b596c4eb708716fb45950876a00f8ce6f4156 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 19 Jul 2013 15:24:04 +0200 Subject: score: Create spinlock implementation header Move implementation specific parts of corespinlock.h and corespinlock.inl into new header file corespinlockimpl.h. The corespinlock.h contains now only the application visible API. --- cpukit/posix/include/rtems/posix/spinlockimpl.h | 1 + cpukit/score/Makefile.am | 5 +- cpukit/score/include/rtems/score/corespinlock.h | 106 +------------- .../score/include/rtems/score/corespinlockimpl.h | 155 +++++++++++++++++++++ cpukit/score/inline/rtems/score/corespinlock.inl | 61 -------- cpukit/score/preinstall.am | 9 +- cpukit/score/src/corespinlock.c | 2 +- cpukit/score/src/corespinlockrelease.c | 2 +- cpukit/score/src/corespinlockwait.c | 2 +- 9 files changed, 171 insertions(+), 172 deletions(-) create mode 100644 cpukit/score/include/rtems/score/corespinlockimpl.h delete mode 100644 cpukit/score/inline/rtems/score/corespinlock.inl (limited to 'cpukit') diff --git a/cpukit/posix/include/rtems/posix/spinlockimpl.h b/cpukit/posix/include/rtems/posix/spinlockimpl.h index 5853d45c82..2711316498 100644 --- a/cpukit/posix/include/rtems/posix/spinlockimpl.h +++ b/cpukit/posix/include/rtems/posix/spinlockimpl.h @@ -20,6 +20,7 @@ #define _RTEMS_POSIX_SPINLOCKIMPL_H #include +#include #include diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index 65abaa4168..6217412e12 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -71,6 +71,7 @@ endif if HAS_PTHREADS include_rtems_score_HEADERS += include/rtems/score/corespinlock.h +include_rtems_score_HEADERS += include/rtems/score/corespinlockimpl.h include_rtems_score_HEADERS += include/rtems/score/corerwlock.h include_rtems_score_HEADERS += include/rtems/score/corerwlockimpl.h endif @@ -108,10 +109,6 @@ include_rtems_score_HEADERS += inline/rtems/score/tqdata.inl include_rtems_score_HEADERS += inline/rtems/score/watchdog.inl include_rtems_score_HEADERS += inline/rtems/score/wkspace.inl -if HAS_PTHREADS -include_rtems_score_HEADERS += inline/rtems/score/corespinlock.inl -endif - if HAS_MP ## We only build multiprocessing related files if HAS_MP was defined include_rtems_score_HEADERS += inline/rtems/score/mppkt.inl diff --git a/cpukit/score/include/rtems/score/corespinlock.h b/cpukit/score/include/rtems/score/corespinlock.h index 5a5b68168a..2c91e835df 100644 --- a/cpukit/score/include/rtems/score/corespinlock.h +++ b/cpukit/score/include/rtems/score/corespinlock.h @@ -19,6 +19,12 @@ #ifndef _RTEMS_SCORE_CORESPINLOCK_H #define _RTEMS_SCORE_CORESPINLOCK_H +#include + +#ifdef __cplusplus +extern "C" { +#endif + /** * @defgroup ScoreSpinlock Spinlock Handler * @@ -29,54 +35,6 @@ */ /**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** - * Core Spinlock handler return statuses. - */ -typedef enum { - /** This status indicates that the operation completed successfully. */ - CORE_SPINLOCK_SUCCESSFUL, - /** This status indicates that the current thread already holds the spinlock. - * An attempt to relock it will result in deadlock. - */ - CORE_SPINLOCK_HOLDER_RELOCKING, - /** This status indicates that the current thread is attempting to unlock a - * spinlock that is held by another thread. - */ - CORE_SPINLOCK_NOT_HOLDER, - /** This status indicates that a thread reached the limit of time it - * was willing to wait on the spin lock. - */ - CORE_SPINLOCK_TIMEOUT, - /** This status indicates that a thread is currently waiting for this - * spin lock. - */ - CORE_SPINLOCK_IS_BUSY, - /** This status indicates that the spinlock is currently locked and thus - * unavailable. - */ - CORE_SPINLOCK_UNAVAILABLE, - /** This status indicates that the spinlock is not currently locked and thus - * should not be released. - */ - CORE_SPINLOCK_NOT_LOCKED -} CORE_spinlock_Status; - -/** This is a shorthand for the last status code. */ -#define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_NOT_LOCKED - -/** This indicates the lock is available. */ -#define CORE_SPINLOCK_UNLOCKED 0 - -/** This indicates the lock is unavailable. */ -#define CORE_SPINLOCK_LOCKED 1 - /** * The following defines the control block used to manage the * attributes of each spinlock. @@ -111,61 +69,11 @@ typedef struct { volatile Objects_Id holder; } CORE_spinlock_Control; -/** - * @brief Initialize the spinlock. - * - * This routine initializes the spinlock based on the parameters passed. - * - * @param[in] the_spinlock is the spinlock control block to initialize - * @param[in] the_spinlock_attributes define the behavior of this instance - */ -void _CORE_spinlock_Initialize( - CORE_spinlock_Control *the_spinlock, - CORE_spinlock_Attributes *the_spinlock_attributes -); - -/** - * @brief Wait for spinlock. - * - * This routine wait for the spinlock to be released. If the spinlock - * is set to automatic and this is the appropriate thread, then it returns - * immediately. Otherwise, the calling thread is blocked until the spinlock - * is released. - * - * @param[in] the_spinlock is the spinlock to wait for - * @param[in] wait is true if willing to wait - * @param[in] timeout is the maximum number of ticks to spin (0 is forever) - * - * @retval A status is returned which indicates the success or failure of - * this operation. - */ -CORE_spinlock_Status _CORE_spinlock_Wait( - CORE_spinlock_Control *the_spinlock, - bool wait, - Watchdog_Interval timeout -); - -/** - * @brief Manually release the spinlock. - * - * This routine manually releases the spinlock. All of the threads waiting - * for the spinlock will be readied. - * - * @param[in] the_spinlock is the spinlock to surrender - */ -CORE_spinlock_Status _CORE_spinlock_Release( - CORE_spinlock_Control *the_spinlock -); - -#ifndef __RTEMS_APPLICATION__ -#include -#endif +/**@}*/ #ifdef __cplusplus } #endif -/**@}*/ - #endif /* end of include file */ diff --git a/cpukit/score/include/rtems/score/corespinlockimpl.h b/cpukit/score/include/rtems/score/corespinlockimpl.h new file mode 100644 index 0000000000..021f2cc110 --- /dev/null +++ b/cpukit/score/include/rtems/score/corespinlockimpl.h @@ -0,0 +1,155 @@ +/** + * @file + * + * @brief Inlined Routines Associated with the SuperCore Spinlock + * + * This include file contains all of the inlined routines associated + * with the SuperCore spinlock. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * 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_SCORE_CORESPINLOCKIMPL_H +#define _RTEMS_SCORE_CORESPINLOCKIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreSpinlock + */ +/**@{**/ + +/** + * Core Spinlock handler return statuses. + */ +typedef enum { + /** This status indicates that the operation completed successfully. */ + CORE_SPINLOCK_SUCCESSFUL, + /** This status indicates that the current thread already holds the spinlock. + * An attempt to relock it will result in deadlock. + */ + CORE_SPINLOCK_HOLDER_RELOCKING, + /** This status indicates that the current thread is attempting to unlock a + * spinlock that is held by another thread. + */ + CORE_SPINLOCK_NOT_HOLDER, + /** This status indicates that a thread reached the limit of time it + * was willing to wait on the spin lock. + */ + CORE_SPINLOCK_TIMEOUT, + /** This status indicates that a thread is currently waiting for this + * spin lock. + */ + CORE_SPINLOCK_IS_BUSY, + /** This status indicates that the spinlock is currently locked and thus + * unavailable. + */ + CORE_SPINLOCK_UNAVAILABLE, + /** This status indicates that the spinlock is not currently locked and thus + * should not be released. + */ + CORE_SPINLOCK_NOT_LOCKED +} CORE_spinlock_Status; + +/** This is a shorthand for the last status code. */ +#define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_NOT_LOCKED + +/** This indicates the lock is available. */ +#define CORE_SPINLOCK_UNLOCKED 0 + +/** This indicates the lock is unavailable. */ +#define CORE_SPINLOCK_LOCKED 1 + +/** + * @brief Initialize the spinlock. + * + * This routine initializes the spinlock based on the parameters passed. + * + * @param[in] the_spinlock is the spinlock control block to initialize + * @param[in] the_spinlock_attributes define the behavior of this instance + */ +void _CORE_spinlock_Initialize( + CORE_spinlock_Control *the_spinlock, + CORE_spinlock_Attributes *the_spinlock_attributes +); + +/** + * @brief Wait for spinlock. + * + * This routine wait for the spinlock to be released. If the spinlock + * is set to automatic and this is the appropriate thread, then it returns + * immediately. Otherwise, the calling thread is blocked until the spinlock + * is released. + * + * @param[in] the_spinlock is the spinlock to wait for + * @param[in] wait is true if willing to wait + * @param[in] timeout is the maximum number of ticks to spin (0 is forever) + * + * @retval A status is returned which indicates the success or failure of + * this operation. + */ +CORE_spinlock_Status _CORE_spinlock_Wait( + CORE_spinlock_Control *the_spinlock, + bool wait, + Watchdog_Interval timeout +); + +/** + * @brief Manually release the spinlock. + * + * This routine manually releases the spinlock. All of the threads waiting + * for the spinlock will be readied. + * + * @param[in] the_spinlock is the spinlock to surrender + */ +CORE_spinlock_Status _CORE_spinlock_Release( + CORE_spinlock_Control *the_spinlock +); + +/** + * This method is used to initialize core spinlock attributes. + * + * @param[in] the_attributes pointer to the attributes to initialize. + */ +RTEMS_INLINE_ROUTINE void _CORE_spinlock_Initialize_attributes( + CORE_spinlock_Attributes *the_attributes +) +{ + the_attributes->XXX = 0; +} + +/** + * This method is used to determine if the spinlock is available or not. + * + * @param[in] the_spinlock will be checked + * + * @return This method will return true if the spinlock is busy + * and false otherwise. + */ +RTEMS_INLINE_ROUTINE bool _CORE_spinlock_Is_busy( + CORE_spinlock_Control *the_spinlock +) +{ + return (the_spinlock->users != 0); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/score/inline/rtems/score/corespinlock.inl b/cpukit/score/inline/rtems/score/corespinlock.inl deleted file mode 100644 index 76f5c4446a..0000000000 --- a/cpukit/score/inline/rtems/score/corespinlock.inl +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines Associated with the SuperCore Spinlock - * - * This include file contains all of the inlined routines associated - * with the SuperCore spinlock. - */ - -/* - * COPYRIGHT (c) 1989-2008. - * 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_SCORE_CORESPINLOCK_H -# error "Never use directly; include instead." -#endif - -#ifndef _RTEMS_SCORE_CORESPINLOCK_INL -#define _RTEMS_SCORE_CORESPINLOCK_INL - -/** - * @addtogroup ScoreSpinlock - */ -/**@{**/ - -/** - * This method is used to initialize core spinlock attributes. - * - * @param[in] the_attributes pointer to the attributes to initialize. - */ -RTEMS_INLINE_ROUTINE void _CORE_spinlock_Initialize_attributes( - CORE_spinlock_Attributes *the_attributes -) -{ - the_attributes->XXX = 0; -} - -/** - * This method is used to determine if the spinlock is available or not. - * - * @param[in] the_spinlock will be checked - * - * @return This method will return true if the spinlock is busy - * and false otherwise. - */ -RTEMS_INLINE_ROUTINE bool _CORE_spinlock_Is_busy( - CORE_spinlock_Control *the_spinlock -) -{ - return (the_spinlock->users != 0); -} - -/** @} */ - -#endif -/* end of include file */ diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am index 294a05fca1..7fb91095f6 100644 --- a/cpukit/score/preinstall.am +++ b/cpukit/score/preinstall.am @@ -253,6 +253,10 @@ $(PROJECT_INCLUDE)/rtems/score/corespinlock.h: include/rtems/score/corespinlock. $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corespinlock.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/corespinlock.h +$(PROJECT_INCLUDE)/rtems/score/corespinlockimpl.h: include/rtems/score/corespinlockimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corespinlockimpl.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/corespinlockimpl.h + $(PROJECT_INCLUDE)/rtems/score/corerwlock.h: include/rtems/score/corerwlock.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corerwlock.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/corerwlock.h @@ -359,11 +363,6 @@ $(PROJECT_INCLUDE)/rtems/score/wkspace.inl: inline/rtems/score/wkspace.inl $(PRO $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/wkspace.inl PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/wkspace.inl -if HAS_PTHREADS -$(PROJECT_INCLUDE)/rtems/score/corespinlock.inl: inline/rtems/score/corespinlock.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corespinlock.inl -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/corespinlock.inl -endif if HAS_MP $(PROJECT_INCLUDE)/rtems/score/mppkt.inl: inline/rtems/score/mppkt.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mppkt.inl diff --git a/cpukit/score/src/corespinlock.c b/cpukit/score/src/corespinlock.c index bc7084e468..013178b501 100644 --- a/cpukit/score/src/corespinlock.c +++ b/cpukit/score/src/corespinlock.c @@ -20,7 +20,7 @@ #endif #include -#include +#include #include #include #include diff --git a/cpukit/score/src/corespinlockrelease.c b/cpukit/score/src/corespinlockrelease.c index bc085f2f01..b2c9b53021 100644 --- a/cpukit/score/src/corespinlockrelease.c +++ b/cpukit/score/src/corespinlockrelease.c @@ -19,7 +19,7 @@ #endif #include -#include +#include #include #include #include diff --git a/cpukit/score/src/corespinlockwait.c b/cpukit/score/src/corespinlockwait.c index 6e71a1fed6..56baad1abf 100644 --- a/cpukit/score/src/corespinlockwait.c +++ b/cpukit/score/src/corespinlockwait.c @@ -19,7 +19,7 @@ #endif #include -#include +#include #include #include #include -- cgit v1.2.3