From 9c743e8e72b602319bf5a4a35a2fea4d60e7dc2e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 18 Jul 2013 13:50:25 +0200 Subject: posix: Create semaphore implementation header Move implementation specific parts of semaphore.h and semaphore.inl into new header file semaphoreimpl.h. The semaphore.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/semaphore.h | 134 +-------------- cpukit/posix/include/rtems/posix/semaphoreimpl.h | 207 +++++++++++++++++++++++ cpukit/posix/inline/rtems/posix/semaphore.inl | 87 ---------- cpukit/posix/preinstall.am | 8 +- cpukit/posix/src/posixtimespecabsolutetimeout.c | 2 +- cpukit/posix/src/semaphore.c | 2 +- cpukit/posix/src/semaphorecreatesupp.c | 2 +- cpukit/posix/src/semaphoredeletesupp.c | 2 +- cpukit/posix/src/semaphoretranslatereturncode.c | 2 +- cpukit/posix/src/semaphorewaitsupp.c | 2 +- cpukit/posix/src/semclose.c | 2 +- cpukit/posix/src/semdestroy.c | 2 +- cpukit/posix/src/semgetvalue.c | 2 +- cpukit/posix/src/seminit.c | 2 +- cpukit/posix/src/semopen.c | 2 +- cpukit/posix/src/sempost.c | 2 +- cpukit/posix/src/semtimedwait.c | 2 +- cpukit/posix/src/semtrywait.c | 2 +- cpukit/posix/src/semunlink.c | 2 +- cpukit/posix/src/semwait.c | 2 +- cpukit/sapi/src/posixapi.c | 2 +- 23 files changed, 239 insertions(+), 235 deletions(-) create mode 100644 cpukit/posix/include/rtems/posix/semaphoreimpl.h delete mode 100644 cpukit/posix/inline/rtems/posix/semaphore.inl (limited to 'cpukit') diff --git a/cpukit/libcsupport/src/resource_snapshot.c b/cpukit/libcsupport/src/resource_snapshot.c index 079b549b40..fba8a2e2a5 100644 --- a/cpukit/libcsupport/src/resource_snapshot.c +++ b/cpukit/libcsupport/src/resource_snapshot.c @@ -36,7 +36,7 @@ #include #include #include - #include + #include #include #include #endif diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am index f108f00d4c..6900ce0c1e 100644 --- a/cpukit/posix/Makefile.am +++ b/cpukit/posix/Makefile.am @@ -39,6 +39,7 @@ include_rtems_posix_HEADERS += include/rtems/posix/psignalimpl.h include_rtems_posix_HEADERS += include/rtems/posix/pthread.h include_rtems_posix_HEADERS += include/rtems/posix/ptimer.h include_rtems_posix_HEADERS += include/rtems/posix/semaphore.h +include_rtems_posix_HEADERS += include/rtems/posix/semaphoreimpl.h include_rtems_posix_HEADERS += include/rtems/posix/threadsup.h include_rtems_posix_HEADERS += include/rtems/posix/time.h include_rtems_posix_HEADERS += include/rtems/posix/timer.h @@ -51,7 +52,6 @@ include_rtems_posix_HEADERS += inline/rtems/posix/key.inl include_rtems_posix_HEADERS += inline/rtems/posix/mqueue.inl include_rtems_posix_HEADERS += inline/rtems/posix/pthread.inl include_rtems_posix_HEADERS += inline/rtems/posix/priority.inl -include_rtems_posix_HEADERS += inline/rtems/posix/semaphore.inl include_rtems_posix_HEADERS += inline/rtems/posix/timer.inl include_rtems_posix_HEADERS += inline/rtems/posix/barrier.inl include_rtems_posix_HEADERS += inline/rtems/posix/rwlock.inl diff --git a/cpukit/posix/include/rtems/posix/semaphore.h b/cpukit/posix/include/rtems/posix/semaphore.h index 92be580c0f..81fee49cce 100644 --- a/cpukit/posix/include/rtems/posix/semaphore.h +++ b/cpukit/posix/include/rtems/posix/semaphore.h @@ -19,6 +19,14 @@ #ifndef _RTEMS_POSIX_SEMAPHORE_H #define _RTEMS_POSIX_SEMAPHORE_H +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + /** * @defgroup POSIXSemaphorePrivate POSIX Semaphore Private Support * @@ -28,14 +36,6 @@ */ /**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - /* * Data Structure used to manage a POSIX semaphore */ @@ -57,127 +57,11 @@ typedef struct { #endif } POSIX_Semaphore_Control; -/* - * The following defines the information control block used to manage - * this class of objects. - */ - -POSIX_EXTERN Objects_Information _POSIX_Semaphore_Information; - -/* - * _POSIX_Semaphore_Manager_initialization - * - * DESCRIPTION: - * - * This routine performs the initialization necessary for this manager. - */ - -void _POSIX_Semaphore_Manager_initialization(void); - -/* - * _POSIX_Semaphore_Allocate - * - * DESCRIPTION: - * - * This function allocates a semaphore control block from - * the inactive chain of free semaphore control blocks. - */ - -RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Allocate( void ); - -/* - * _POSIX_Semaphore_Free - * - * DESCRIPTION: - * - * This routine frees a semaphore control block to the - * inactive chain of free semaphore control blocks. - */ - -RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free ( - POSIX_Semaphore_Control *the_semaphore -); - -/* - * _POSIX_Semaphore_Get - * - * DESCRIPTION: - * - * This function maps semaphore IDs to semaphore control blocks. - * If ID corresponds to a local semaphore, then it returns - * the_semaphore control pointer which maps to ID and location - * is set to OBJECTS_LOCAL. if the semaphore ID is global and - * resides on a remote node, then location is set to OBJECTS_REMOTE, - * and the_semaphore is undefined. Otherwise, location is set - * to OBJECTS_ERROR and the_semaphore is undefined. - */ - -RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get ( - sem_t *id, - Objects_Locations *location -); - -/* - * _POSIX_Semaphore_Create_support - * - * DESCRIPTION: - * - * This routine supports the sem_init and sem_open routines. - */ - -int _POSIX_Semaphore_Create_support( - const char *name, - size_t name_len, - int pshared, - unsigned int value, - POSIX_Semaphore_Control **the_sem -); - -/** - * @brief POSIX delete a semaphore. - * - * DESCRIPTION: - * - * This routine supports the sem_close and sem_unlink routines. - */ -void _POSIX_Semaphore_Delete( - POSIX_Semaphore_Control *the_semaphore -); - -/** - * @brief POSIX semaphore wait support. - * - * DESCRIPTION: - * - * This routine supports the sem_wait, sem_trywait, and sem_timedwait - * services. - */ -int _POSIX_Semaphore_Wait_support( - sem_t *sem, - bool blocking, - Watchdog_Interval timeout -); - -/* - * _POSIX_Semaphore_Translate_core_semaphore_return_code - * - * DESCRIPTION: - * - * A support routine which converts core semaphore status codes into the - * appropriate POSIX status values. - */ - -int _POSIX_Semaphore_Translate_core_semaphore_return_code( - CORE_semaphore_Status the_semaphore_status -); - -#include +/** @} */ #ifdef __cplusplus } #endif -/** @} */ - #endif /* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/semaphoreimpl.h b/cpukit/posix/include/rtems/posix/semaphoreimpl.h new file mode 100644 index 0000000000..6d1939fe43 --- /dev/null +++ b/cpukit/posix/include/rtems/posix/semaphoreimpl.h @@ -0,0 +1,207 @@ +/** + * @file + * + * @brief Private Inlined Routines for POSIX Semaphores + * + * This include file contains the static inline implementation of the private + * inlined routines for POSIX Semaphores. + */ + +/* + * 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_SEMAPHOREIMPL_H +#define _RTEMS_POSIX_SEMAPHOREIMPL_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_Semaphore_Information; + +/* + * _POSIX_Semaphore_Manager_initialization + * + * DESCRIPTION: + * + * This routine performs the initialization necessary for this manager. + */ + +void _POSIX_Semaphore_Manager_initialization(void); + +/* + * _POSIX_Semaphore_Allocate + * + * DESCRIPTION: + * + * This function allocates a semaphore control block from + * the inactive chain of free semaphore control blocks. + */ + +RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Allocate( void ); + +/* + * _POSIX_Semaphore_Free + * + * DESCRIPTION: + * + * This routine frees a semaphore control block to the + * inactive chain of free semaphore control blocks. + */ + +RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free ( + POSIX_Semaphore_Control *the_semaphore +); + +/* + * _POSIX_Semaphore_Get + * + * DESCRIPTION: + * + * This function maps semaphore IDs to semaphore control blocks. + * If ID corresponds to a local semaphore, then it returns + * the_semaphore control pointer which maps to ID and location + * is set to OBJECTS_LOCAL. if the semaphore ID is global and + * resides on a remote node, then location is set to OBJECTS_REMOTE, + * and the_semaphore is undefined. Otherwise, location is set + * to OBJECTS_ERROR and the_semaphore is undefined. + */ + +RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get ( + sem_t *id, + Objects_Locations *location +); + +/* + * _POSIX_Semaphore_Create_support + * + * DESCRIPTION: + * + * This routine supports the sem_init and sem_open routines. + */ + +int _POSIX_Semaphore_Create_support( + const char *name, + size_t name_len, + int pshared, + unsigned int value, + POSIX_Semaphore_Control **the_sem +); + +/** + * @brief POSIX delete a semaphore. + * + * DESCRIPTION: + * + * This routine supports the sem_close and sem_unlink routines. + */ +void _POSIX_Semaphore_Delete( + POSIX_Semaphore_Control *the_semaphore +); + +/** + * @brief POSIX semaphore wait support. + * + * DESCRIPTION: + * + * This routine supports the sem_wait, sem_trywait, and sem_timedwait + * services. + */ +int _POSIX_Semaphore_Wait_support( + sem_t *sem, + bool blocking, + Watchdog_Interval timeout +); + +/* + * _POSIX_Semaphore_Translate_core_semaphore_return_code + * + * DESCRIPTION: + * + * A support routine which converts core semaphore status codes into the + * appropriate POSIX status values. + */ + +int _POSIX_Semaphore_Translate_core_semaphore_return_code( + CORE_semaphore_Status the_semaphore_status +); + +/* + * _POSIX_Semaphore_Allocate + */ + +RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Allocate( void ) +{ + return (POSIX_Semaphore_Control *) + _Objects_Allocate( &_POSIX_Semaphore_Information ); +} + +/* + * _POSIX_Semaphore_Free + */ + +RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free ( + POSIX_Semaphore_Control *the_semaphore +) +{ + _Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object ); +} + +/* + * _POSIX_Semaphore_Namespace_remove + */ + +RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove ( + POSIX_Semaphore_Control *the_semaphore +) +{ + _Objects_Namespace_remove( + &_POSIX_Semaphore_Information, &the_semaphore->Object ); +} + + + +/* + * _POSIX_Semaphore_Get + */ +RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get ( + sem_t *id, + Objects_Locations *location +) +{ + return (POSIX_Semaphore_Control *) + _Objects_Get( &_POSIX_Semaphore_Information, (Objects_Id)*id, location ); +} + +/** + * @see _POSIX_Name_to_id(). + */ +RTEMS_INLINE_ROUTINE int _POSIX_Semaphore_Name_to_id( + const char *name, + Objects_Id *id, + size_t *len +) +{ + return _POSIX_Name_to_id( &_POSIX_Semaphore_Information, name, id, len ); +} + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/posix/inline/rtems/posix/semaphore.inl b/cpukit/posix/inline/rtems/posix/semaphore.inl deleted file mode 100644 index 49c5e1badf..0000000000 --- a/cpukit/posix/inline/rtems/posix/semaphore.inl +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @file - * - * @brief Private Inlined Routines for POSIX Semaphores - * - * This include file contains the static inline implementation of the private - * inlined routines for POSIX Semaphores. - */ - -/* - * 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_SEMAPHORE_H -# error "Never use directly; include instead." -#endif - -#ifndef _RTEMS_POSIX_SEMAPHORE_INL -#define _RTEMS_POSIX_SEMAPHORE_INL - -/* - * _POSIX_Semaphore_Allocate - */ - -RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Allocate( void ) -{ - return (POSIX_Semaphore_Control *) - _Objects_Allocate( &_POSIX_Semaphore_Information ); -} - -/* - * _POSIX_Semaphore_Free - */ - -RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free ( - POSIX_Semaphore_Control *the_semaphore -) -{ - _Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object ); -} - -/* - * _POSIX_Semaphore_Namespace_remove - */ - -RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove ( - POSIX_Semaphore_Control *the_semaphore -) -{ - _Objects_Namespace_remove( - &_POSIX_Semaphore_Information, &the_semaphore->Object ); -} - - - -/* - * _POSIX_Semaphore_Get - */ -RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get ( - sem_t *id, - Objects_Locations *location -) -{ - return (POSIX_Semaphore_Control *) - _Objects_Get( &_POSIX_Semaphore_Information, (Objects_Id)*id, location ); -} - -/** - * @see _POSIX_Name_to_id(). - */ -RTEMS_INLINE_ROUTINE int _POSIX_Semaphore_Name_to_id( - const char *name, - Objects_Id *id, - size_t *len -) -{ - return _POSIX_Name_to_id( &_POSIX_Semaphore_Information, name, id, len ); -} - -#endif -/* end of include file */ - diff --git a/cpukit/posix/preinstall.am b/cpukit/posix/preinstall.am index 74ceb42c14..0fda0df408 100644 --- a/cpukit/posix/preinstall.am +++ b/cpukit/posix/preinstall.am @@ -100,6 +100,10 @@ $(PROJECT_INCLUDE)/rtems/posix/semaphore.h: include/rtems/posix/semaphore.h $(PR $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/semaphore.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/semaphore.h +$(PROJECT_INCLUDE)/rtems/posix/semaphoreimpl.h: include/rtems/posix/semaphoreimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/semaphoreimpl.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/semaphoreimpl.h + $(PROJECT_INCLUDE)/rtems/posix/threadsup.h: include/rtems/posix/threadsup.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/threadsup.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/threadsup.h @@ -144,10 +148,6 @@ $(PROJECT_INCLUDE)/rtems/posix/priority.inl: inline/rtems/posix/priority.inl $(P $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/priority.inl PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/priority.inl -$(PROJECT_INCLUDE)/rtems/posix/semaphore.inl: inline/rtems/posix/semaphore.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/semaphore.inl -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/semaphore.inl - $(PROJECT_INCLUDE)/rtems/posix/timer.inl: inline/rtems/posix/timer.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/timer.inl PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/timer.inl diff --git a/cpukit/posix/src/posixtimespecabsolutetimeout.c b/cpukit/posix/src/posixtimespecabsolutetimeout.c index e94805e692..913de6c9c0 100644 --- a/cpukit/posix/src/posixtimespecabsolutetimeout.c +++ b/cpukit/posix/src/posixtimespecabsolutetimeout.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semaphore.c b/cpukit/posix/src/semaphore.c index 58da098501..21d67c5646 100644 --- a/cpukit/posix/src/semaphore.c +++ b/cpukit/posix/src/semaphore.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semaphorecreatesupp.c b/cpukit/posix/src/semaphorecreatesupp.c index 026e7fafcd..fecbdb5f48 100644 --- a/cpukit/posix/src/semaphorecreatesupp.c +++ b/cpukit/posix/src/semaphorecreatesupp.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semaphoredeletesupp.c b/cpukit/posix/src/semaphoredeletesupp.c index a24adef870..6e46f53511 100644 --- a/cpukit/posix/src/semaphoredeletesupp.c +++ b/cpukit/posix/src/semaphoredeletesupp.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semaphoretranslatereturncode.c b/cpukit/posix/src/semaphoretranslatereturncode.c index 44885d6085..c4e65580c7 100644 --- a/cpukit/posix/src/semaphoretranslatereturncode.c +++ b/cpukit/posix/src/semaphoretranslatereturncode.c @@ -25,7 +25,7 @@ #include #include -#include +#include /* * _POSIX_Semaphore_Translate_core_semaphore_return_code diff --git a/cpukit/posix/src/semaphorewaitsupp.c b/cpukit/posix/src/semaphorewaitsupp.c index f3ce6003d1..67ecb43858 100644 --- a/cpukit/posix/src/semaphorewaitsupp.c +++ b/cpukit/posix/src/semaphorewaitsupp.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semclose.c b/cpukit/posix/src/semclose.c index 07f75367df..81cb3161d5 100644 --- a/cpukit/posix/src/semclose.c +++ b/cpukit/posix/src/semclose.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semdestroy.c b/cpukit/posix/src/semdestroy.c index cef340620a..0e547df205 100644 --- a/cpukit/posix/src/semdestroy.c +++ b/cpukit/posix/src/semdestroy.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semgetvalue.c b/cpukit/posix/src/semgetvalue.c index 24527d16a1..3e584e2311 100644 --- a/cpukit/posix/src/semgetvalue.c +++ b/cpukit/posix/src/semgetvalue.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/seminit.c b/cpukit/posix/src/seminit.c index f0dcb7137f..39a75b5e2b 100644 --- a/cpukit/posix/src/seminit.c +++ b/cpukit/posix/src/seminit.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semopen.c b/cpukit/posix/src/semopen.c index 113c622e97..c74925b4c9 100644 --- a/cpukit/posix/src/semopen.c +++ b/cpukit/posix/src/semopen.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/sempost.c b/cpukit/posix/src/sempost.c index 79e5ec83ff..6b9f87648f 100644 --- a/cpukit/posix/src/sempost.c +++ b/cpukit/posix/src/sempost.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semtimedwait.c b/cpukit/posix/src/semtimedwait.c index 9f54ad3add..6d4157984b 100644 --- a/cpukit/posix/src/semtimedwait.c +++ b/cpukit/posix/src/semtimedwait.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semtrywait.c b/cpukit/posix/src/semtrywait.c index b80e515afd..2aa6d284bd 100644 --- a/cpukit/posix/src/semtrywait.c +++ b/cpukit/posix/src/semtrywait.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semunlink.c b/cpukit/posix/src/semunlink.c index c34add8131..cee2a6427e 100644 --- a/cpukit/posix/src/semunlink.c +++ b/cpukit/posix/src/semunlink.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/semwait.c b/cpukit/posix/src/semwait.c index 16fc9076d4..fbc59e44a8 100644 --- a/cpukit/posix/src/semwait.c +++ b/cpukit/posix/src/semwait.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c index 158180991f..bda9a28928 100644 --- a/cpukit/sapi/src/posixapi.c +++ b/cpukit/sapi/src/posixapi.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include -- cgit v1.2.3