From eb448eece9305b2bba641471a428af4dad97effc Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 19 Jul 2013 15:18:08 +0200 Subject: posix: Create spinlock implementation header Move implementation specific parts of spinlock.h and spinlock.inl into new header file spinlockimpl.h. The spinlock.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/spinlock.h | 39 +------ cpukit/posix/include/rtems/posix/spinlockimpl.h | 131 ++++++++++++++++++++++++ cpukit/posix/inline/rtems/posix/spinlock.inl | 96 ----------------- cpukit/posix/preinstall.am | 8 +- cpukit/posix/src/pspin.c | 2 +- cpukit/posix/src/pspindestroy.c | 2 +- cpukit/posix/src/pspininit.c | 2 +- cpukit/posix/src/pspinlock.c | 2 +- cpukit/posix/src/pspinlocktranslatereturncode.c | 2 +- cpukit/posix/src/pspintrylock.c | 2 +- cpukit/posix/src/pspinunlock.c | 2 +- cpukit/sapi/src/posixapi.c | 2 +- 14 files changed, 148 insertions(+), 146 deletions(-) create mode 100644 cpukit/posix/include/rtems/posix/spinlockimpl.h delete mode 100644 cpukit/posix/inline/rtems/posix/spinlock.inl diff --git a/cpukit/libcsupport/src/resource_snapshot.c b/cpukit/libcsupport/src/resource_snapshot.c index 48bbdc8306..3318d38ddd 100644 --- a/cpukit/libcsupport/src/resource_snapshot.c +++ b/cpukit/libcsupport/src/resource_snapshot.c @@ -39,7 +39,7 @@ #include #include #include - #include + #include #include #endif diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am index 9bea73b56c..e7ec45f81c 100644 --- a/cpukit/posix/Makefile.am +++ b/cpukit/posix/Makefile.am @@ -52,9 +52,9 @@ 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 += include/rtems/posix/spinlockimpl.h include_rtems_posix_HEADERS += inline/rtems/posix/key.inl -include_rtems_posix_HEADERS += inline/rtems/posix/spinlock.inl ## src libposix_a_SOURCES += src/aio_cancel.c src/aio_error.c src/aio_fsync.c \ diff --git a/cpukit/posix/include/rtems/posix/spinlock.h b/cpukit/posix/include/rtems/posix/spinlock.h index 34b04ebbc9..c27a8c1907 100644 --- a/cpukit/posix/include/rtems/posix/spinlock.h +++ b/cpukit/posix/include/rtems/posix/spinlock.h @@ -25,6 +25,9 @@ #ifndef _RTEMS_POSIX_SPINLOCK_H #define _RTEMS_POSIX_SPINLOCK_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 spinlock. */ @@ -53,39 +53,6 @@ typedef struct { CORE_spinlock_Control Spinlock; } POSIX_Spinlock_Control; -/** - * The following defines the information control block used to manage - * this class of objects. - */ - -POSIX_EXTERN Objects_Information _POSIX_Spinlock_Information; - -/** - * @brief POSIX spinlock manager initialization. - * - * This routine performs the initialization necessary for this manager. - */ - -void _POSIX_Spinlock_Manager_initialization(void); - -/** - * @brief Translate core spinlock status code. - * - * This routine translates SuperCore Spinlock status codes into the - * corresponding POSIX ones. - * - * @param[in] the_spinlock_status is the SuperCore status. - * - * @return the corresponding POSIX status - */ -int _POSIX_Spinlock_Translate_core_spinlock_return_code( - CORE_spinlock_Status the_spinlock_status -); - -#ifndef __RTEMS_APPLICATION__ -#include -#endif - /** @} */ #ifdef __cplusplus diff --git a/cpukit/posix/include/rtems/posix/spinlockimpl.h b/cpukit/posix/include/rtems/posix/spinlockimpl.h new file mode 100644 index 0000000000..5853d45c82 --- /dev/null +++ b/cpukit/posix/include/rtems/posix/spinlockimpl.h @@ -0,0 +1,131 @@ +/** + * @file + * + * @brief Inlined Routines from the POSIX Spinlock Manager + * + * This file contains the static inlin implementation of the inlined + * routines from the POSIX Spinlock 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_SPINLOCKIMPL_H +#define _RTEMS_POSIX_SPINLOCKIMPL_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_Spinlock_Information; + +/** + * @brief POSIX spinlock manager initialization. + * + * This routine performs the initialization necessary for this manager. + */ + +void _POSIX_Spinlock_Manager_initialization(void); + +/** + * @brief Translate core spinlock status code. + * + * This routine translates SuperCore Spinlock status codes into the + * corresponding POSIX ones. + * + * @param[in] the_spinlock_status is the SuperCore status. + * + * @return the corresponding POSIX status + */ +int _POSIX_Spinlock_Translate_core_spinlock_return_code( + CORE_spinlock_Status the_spinlock_status +); + +/** + * @brief Allocate a spinlock control block. + * + * This function allocates a spinlock control block from + * the inactive chain of free spinlock control blocks. + */ +RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Allocate( void ) +{ + return (POSIX_Spinlock_Control *) + _Objects_Allocate( &_POSIX_Spinlock_Information ); +} + +/** + * @brief Free a spinlock control block. + * + * This routine frees a spinlock control block to the + * inactive chain of free spinlock control blocks. + */ +RTEMS_INLINE_ROUTINE void _POSIX_Spinlock_Free ( + POSIX_Spinlock_Control *the_spinlock +) +{ + _Objects_Free( &_POSIX_Spinlock_Information, &the_spinlock->Object ); +} + +/** + * @brief Get a spinlock control block. + * + * This function maps spinlock IDs to spinlock control blocks. + * If ID corresponds to a local spinlock, then it returns + * the_spinlock control pointer which maps to ID and location + * is set to OBJECTS_LOCAL. if the spinlock ID is global and + * resides on a remote node, then location is set to OBJECTS_REMOTE, + * and the_spinlock is undefined. Otherwise, location is set + * to OBJECTS_ERROR and the_spinlock is undefined. + */ +RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Get ( + pthread_spinlock_t *spinlock, + Objects_Locations *location +) +{ + return (POSIX_Spinlock_Control *) _Objects_Get( + &_POSIX_Spinlock_Information, + (Objects_Id) *spinlock, + location + ); +} + +/** + * @brief Check if a spinlock control block is NULL. + * + * This function returns @c TRUE if the_spinlock is @c NULL and @c FALSE + * otherwise. + * + * @param[in] the_spinlock is the pointer to the spinlock control block + * to be checked. + * + * @retval TRUE The spinlock control block is @c NULL. + * @retval FALSE The spinlock control block is not @c NULL. + */ +RTEMS_INLINE_ROUTINE bool _POSIX_Spinlock_Is_null ( + POSIX_Spinlock_Control *the_spinlock +) +{ + return ( the_spinlock == NULL ); +} + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/posix/inline/rtems/posix/spinlock.inl b/cpukit/posix/inline/rtems/posix/spinlock.inl deleted file mode 100644 index b8ababda02..0000000000 --- a/cpukit/posix/inline/rtems/posix/spinlock.inl +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines from the POSIX Spinlock Manager - * - * This file contains the static inlin implementation of the inlined - * routines from the POSIX Spinlock 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_SPINLOCK_H -# error "Never use directly; include instead." -#endif - -#ifndef _RTEMS_POSIX_SPINLOCK_INL -#define _RTEMS_POSIX_SPINLOCK_INL - -#include - -/** - * @brief Allocate a spinlock control block. - * - * This function allocates a spinlock control block from - * the inactive chain of free spinlock control blocks. - */ -RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Allocate( void ) -{ - return (POSIX_Spinlock_Control *) - _Objects_Allocate( &_POSIX_Spinlock_Information ); -} - -/** - * @brief Free a spinlock control block. - * - * This routine frees a spinlock control block to the - * inactive chain of free spinlock control blocks. - */ -RTEMS_INLINE_ROUTINE void _POSIX_Spinlock_Free ( - POSIX_Spinlock_Control *the_spinlock -) -{ - _Objects_Free( &_POSIX_Spinlock_Information, &the_spinlock->Object ); -} - -/** - * @brief Get a spinlock control block. - * - * This function maps spinlock IDs to spinlock control blocks. - * If ID corresponds to a local spinlock, then it returns - * the_spinlock control pointer which maps to ID and location - * is set to OBJECTS_LOCAL. if the spinlock ID is global and - * resides on a remote node, then location is set to OBJECTS_REMOTE, - * and the_spinlock is undefined. Otherwise, location is set - * to OBJECTS_ERROR and the_spinlock is undefined. - */ -RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Get ( - pthread_spinlock_t *spinlock, - Objects_Locations *location -) -{ - return (POSIX_Spinlock_Control *) _Objects_Get( - &_POSIX_Spinlock_Information, - (Objects_Id) *spinlock, - location - ); -} - -/** - * @brief Check if a spinlock control block is NULL. - * - * This function returns @c TRUE if the_spinlock is @c NULL and @c FALSE - * otherwise. - * - * @param[in] the_spinlock is the pointer to the spinlock control block - * to be checked. - * - * @retval TRUE The spinlock control block is @c NULL. - * @retval FALSE The spinlock control block is not @c NULL. - */ -RTEMS_INLINE_ROUTINE bool _POSIX_Spinlock_Is_null ( - POSIX_Spinlock_Control *the_spinlock -) -{ - return ( the_spinlock == NULL ); -} - -#endif -/* end of include file */ diff --git a/cpukit/posix/preinstall.am b/cpukit/posix/preinstall.am index 7cb8ee8348..3ae3896ec9 100644 --- a/cpukit/posix/preinstall.am +++ b/cpukit/posix/preinstall.am @@ -152,11 +152,11 @@ $(PROJECT_INCLUDE)/rtems/posix/spinlock.h: include/rtems/posix/spinlock.h $(PROJ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/spinlock.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/spinlock.h +$(PROJECT_INCLUDE)/rtems/posix/spinlockimpl.h: include/rtems/posix/spinlockimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/spinlockimpl.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/spinlockimpl.h + $(PROJECT_INCLUDE)/rtems/posix/key.inl: inline/rtems/posix/key.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/key.inl PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/key.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 endif diff --git a/cpukit/posix/src/pspin.c b/cpukit/posix/src/pspin.c index 27a897339e..a31cb5d24d 100644 --- a/cpukit/posix/src/pspin.c +++ b/cpukit/posix/src/pspin.c @@ -29,7 +29,7 @@ #include #include -#include +#include /** * @brief _POSIX_Spinlock_Manager_initialization diff --git a/cpukit/posix/src/pspindestroy.c b/cpukit/posix/src/pspindestroy.c index f7243540b6..4b8485074e 100644 --- a/cpukit/posix/src/pspindestroy.c +++ b/cpukit/posix/src/pspindestroy.c @@ -22,7 +22,7 @@ #include #include -#include +#include /** * This directive allows a thread to delete a spinlock specified by diff --git a/cpukit/posix/src/pspininit.c b/cpukit/posix/src/pspininit.c index 164cb5039f..fc65177701 100644 --- a/cpukit/posix/src/pspininit.c +++ b/cpukit/posix/src/pspininit.c @@ -24,7 +24,7 @@ #include #include -#include +#include /* * pthread_spinlock_init diff --git a/cpukit/posix/src/pspinlock.c b/cpukit/posix/src/pspinlock.c index 2f4bfffaa6..a48750f6d2 100644 --- a/cpukit/posix/src/pspinlock.c +++ b/cpukit/posix/src/pspinlock.c @@ -22,7 +22,7 @@ #include #include -#include +#include /** * This directive allows a thread to wait at a spinlock. diff --git a/cpukit/posix/src/pspinlocktranslatereturncode.c b/cpukit/posix/src/pspinlocktranslatereturncode.c index ce133a40b7..a77284adef 100644 --- a/cpukit/posix/src/pspinlocktranslatereturncode.c +++ b/cpukit/posix/src/pspinlocktranslatereturncode.c @@ -23,7 +23,7 @@ #include #include -#include +#include static int _POSIX_Spinlock_Return_codes[CORE_SPINLOCK_STATUS_LAST + 1] = { 0, /* CORE_SPINLOCK_SUCCESSFUL */ diff --git a/cpukit/posix/src/pspintrylock.c b/cpukit/posix/src/pspintrylock.c index 7f7c6c17e1..0aa3aab7bb 100644 --- a/cpukit/posix/src/pspintrylock.c +++ b/cpukit/posix/src/pspintrylock.c @@ -22,7 +22,7 @@ #include #include -#include +#include /* * pthread_spin_trylock diff --git a/cpukit/posix/src/pspinunlock.c b/cpukit/posix/src/pspinunlock.c index dc43d1d1c9..7e4e830024 100644 --- a/cpukit/posix/src/pspinunlock.c +++ b/cpukit/posix/src/pspinunlock.c @@ -24,7 +24,7 @@ #include #include -#include +#include /* * pthread_spin_unlock diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c index 6cdffa7a28..7563e82e0c 100644 --- a/cpukit/sapi/src/posixapi.c +++ b/cpukit/sapi/src/posixapi.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include Objects_Information *_POSIX_Objects[ OBJECTS_POSIX_CLASSES_LAST + 1 ]; -- cgit v1.2.3