From 35210b128c28c1edd6b35aa97a949abf683f113a Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 19 Jul 2013 12:08:02 +0200 Subject: posix: Create condition variable impl header Move implementation specific parts of cond.h and cond.inl into new header file condimpl.h. The cond.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/cond.h | 155 ++------------------- cpukit/posix/include/rtems/posix/condimpl.h | 202 ++++++++++++++++++++++++++++ cpukit/posix/inline/rtems/posix/cond.inl | 64 --------- cpukit/posix/preinstall.am | 8 +- cpukit/posix/src/barrierattrdestroy.c | 2 +- cpukit/posix/src/cond.c | 2 +- cpukit/posix/src/condattrdestroy.c | 2 +- cpukit/posix/src/condattrgetpshared.c | 2 +- cpukit/posix/src/condattrinit.c | 2 +- cpukit/posix/src/condattrsetpshared.c | 2 +- cpukit/posix/src/condbroadcast.c | 2 +- cpukit/posix/src/conddefaultattributes.c | 2 +- cpukit/posix/src/conddestroy.c | 2 +- cpukit/posix/src/condget.c | 2 +- cpukit/posix/src/condinit.c | 2 +- cpukit/posix/src/condsignal.c | 2 +- cpukit/posix/src/condsignalsupp.c | 2 +- cpukit/posix/src/condtimedwait.c | 2 +- cpukit/posix/src/condwait.c | 2 +- cpukit/posix/src/condwaitsupp.c | 2 +- cpukit/posix/src/rwlockattrdestroy.c | 2 +- cpukit/sapi/src/posixapi.c | 2 +- 24 files changed, 237 insertions(+), 232 deletions(-) create mode 100644 cpukit/posix/include/rtems/posix/condimpl.h delete mode 100644 cpukit/posix/inline/rtems/posix/cond.inl diff --git a/cpukit/libcsupport/src/resource_snapshot.c b/cpukit/libcsupport/src/resource_snapshot.c index 8d2a05c936..e7de01d27d 100644 --- a/cpukit/libcsupport/src/resource_snapshot.c +++ b/cpukit/libcsupport/src/resource_snapshot.c @@ -31,7 +31,7 @@ #ifdef RTEMS_POSIX_API #include - #include + #include #include #include #include diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am index a7a4111236..2ad712b04b 100644 --- a/cpukit/posix/Makefile.am +++ b/cpukit/posix/Makefile.am @@ -27,6 +27,7 @@ include_HEADERS += include/semaphore.h include_rtems_posix_HEADERS += include/rtems/posix/aio_misc.h include_rtems_posix_HEADERS += include/rtems/posix/cancel.h include_rtems_posix_HEADERS += include/rtems/posix/cond.h +include_rtems_posix_HEADERS += include/rtems/posix/condimpl.h include_rtems_posix_HEADERS += include/rtems/posix/config.h include_rtems_posix_HEADERS += include/rtems/posix/key.h include_rtems_posix_HEADERS += include/rtems/posix/mqueue.h @@ -49,7 +50,6 @@ 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/spinlock.h -include_rtems_posix_HEADERS += inline/rtems/posix/cond.inl include_rtems_posix_HEADERS += inline/rtems/posix/key.inl include_rtems_posix_HEADERS += inline/rtems/posix/pthread.inl include_rtems_posix_HEADERS += inline/rtems/posix/priority.inl diff --git a/cpukit/posix/include/rtems/posix/cond.h b/cpukit/posix/include/rtems/posix/cond.h index 8ff34e0ce6..0e3e68ccd1 100644 --- a/cpukit/posix/include/rtems/posix/cond.h +++ b/cpukit/posix/include/rtems/posix/cond.h @@ -19,6 +19,15 @@ #ifndef _RTEMS_POSIX_COND_H #define _RTEMS_POSIX_COND_H +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + /** * @defgroup POSIX_COND_VARS POSIX Condition Variables * @@ -26,19 +35,6 @@ * */ /**@{**/ -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* - * Constant to indicate condition variable does not currently have - * a mutex assigned to it. - */ - -#define POSIX_CONDITION_VARIABLES_NO_MUTEX 0 /* * Data Structure used to manage a POSIX condition variable @@ -51,140 +47,11 @@ typedef struct { Thread_queue_Control Wait_queue; } POSIX_Condition_variables_Control; -/* - * The following defines the information control block used to manage - * this class of objects. - */ - -POSIX_EXTERN Objects_Information _POSIX_Condition_variables_Information; - -/* - * The default condition variable attributes structure. - */ - -extern const pthread_condattr_t _POSIX_Condition_variables_Default_attributes; - -/* - * @brief Initialization Necessary for this Manager - * - * _POSIX_Condition_variables_Manager_initialization - * - * DESCRIPTION: - * - * This routine performs the initialization necessary for this manager. - */ - -void _POSIX_Condition_variables_Manager_initialization(void); - -/* - * _POSIX_Condition_variables_Allocate - * - * DESCRIPTION: - * - * This function allocates a condition variable control block from - * the inactive chain of free condition variable control blocks. - */ - -RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control * - _POSIX_Condition_variables_Allocate( void ); - -/* - * _POSIX_Condition_variables_Free - * - * DESCRIPTION: - * - * This routine frees a condition variable control block to the - * inactive chain of free condition variable control blocks. - */ - -RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Free ( - POSIX_Condition_variables_Control *the_condition_variable -); - -/* - * _POSIX_Condition_variables_Get - * - * DESCRIPTION: - * - * This function maps condition variable IDs to condition variable control - * blocks. If ID corresponds to a local condition variable, then it returns - * the_condition variable control pointer which maps to ID and location - * is set to OBJECTS_LOCAL. if the condition variable ID is global and - * resides on a remote node, then location is set to OBJECTS_REMOTE, - * and the_condition variable is undefined. Otherwise, location is set - * to OBJECTS_ERROR and the_condition variable is undefined. - */ - -#if 0 -RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get ( - Objects_Id *id, - Objects_Locations *location -); -#endif - -/* - * _POSIX_Condition_variables_Is_null - * - * DESCRIPTION: - * - * This function returns TRUE if the_condition variable is NULL - * and FALSE otherwise. - */ - -RTEMS_INLINE_ROUTINE bool _POSIX_Condition_variables_Is_null ( - POSIX_Condition_variables_Control *the_condition_variable -); - -/** - * @brief Implements wake up version of the "signal" operation. - * - * DESCRIPTION: - * - * A support routine which implements guts of the broadcast and single task - * wake up version of the "signal" operation. - */ -int _POSIX_Condition_variables_Signal_support( - pthread_cond_t *cond, - bool is_broadcast -); - -/** - * @brief POSIX condition variables wait support. - * - * DESCRIPTION: - * - * A support routine which implements guts of the blocking, non-blocking, and - * timed wait version of condition variable wait routines. - */ -int _POSIX_Condition_variables_Wait_support( - pthread_cond_t *cond, - pthread_mutex_t *mutex, - Watchdog_Interval timeout, - bool already_timedout -); - -/* - * _POSIX_Condition_variables_Get - * - * DESCRIPTION: - * - * A support routine which translates the condition variable id into - * a local pointer. As a side-effect, it may create the condition - * variable. - */ - -POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get ( - pthread_cond_t *cond, - Objects_Locations *location -); - -#include - -/** @} */ - #ifdef __cplusplus } #endif +/** @} */ + #endif /* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/condimpl.h b/cpukit/posix/include/rtems/posix/condimpl.h new file mode 100644 index 0000000000..0e6d3409c1 --- /dev/null +++ b/cpukit/posix/include/rtems/posix/condimpl.h @@ -0,0 +1,202 @@ +/** + * @file rtems/posix/cond.inl + * + * This include file contains the static inline implementation of the private + * inlined routines for POSIX condition variables. + */ + +/* + * 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_CONDIMPL_H +#define _RTEMS_POSIX_CONDIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Constant to indicate condition variable does not currently have + * a mutex assigned to it. + */ + +#define POSIX_CONDITION_VARIABLES_NO_MUTEX 0 + +/* + * The following defines the information control block used to manage + * this class of objects. + */ + +POSIX_EXTERN Objects_Information _POSIX_Condition_variables_Information; + +/* + * The default condition variable attributes structure. + */ + +extern const pthread_condattr_t _POSIX_Condition_variables_Default_attributes; + +/* + * @brief Initialization Necessary for this Manager + * + * _POSIX_Condition_variables_Manager_initialization + * + * DESCRIPTION: + * + * This routine performs the initialization necessary for this manager. + */ + +void _POSIX_Condition_variables_Manager_initialization(void); + +/* + * _POSIX_Condition_variables_Allocate + * + * DESCRIPTION: + * + * This function allocates a condition variable control block from + * the inactive chain of free condition variable control blocks. + */ + +RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control * + _POSIX_Condition_variables_Allocate( void ); + +/* + * _POSIX_Condition_variables_Free + * + * DESCRIPTION: + * + * This routine frees a condition variable control block to the + * inactive chain of free condition variable control blocks. + */ + +RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Free ( + POSIX_Condition_variables_Control *the_condition_variable +); + +/* + * _POSIX_Condition_variables_Get + * + * DESCRIPTION: + * + * This function maps condition variable IDs to condition variable control + * blocks. If ID corresponds to a local condition variable, then it returns + * the_condition variable control pointer which maps to ID and location + * is set to OBJECTS_LOCAL. if the condition variable ID is global and + * resides on a remote node, then location is set to OBJECTS_REMOTE, + * and the_condition variable is undefined. Otherwise, location is set + * to OBJECTS_ERROR and the_condition variable is undefined. + */ + +#if 0 +RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get ( + Objects_Id *id, + Objects_Locations *location +); +#endif + +/* + * _POSIX_Condition_variables_Is_null + * + * DESCRIPTION: + * + * This function returns TRUE if the_condition variable is NULL + * and FALSE otherwise. + */ + +RTEMS_INLINE_ROUTINE bool _POSIX_Condition_variables_Is_null ( + POSIX_Condition_variables_Control *the_condition_variable +); + +/** + * @brief Implements wake up version of the "signal" operation. + * + * DESCRIPTION: + * + * A support routine which implements guts of the broadcast and single task + * wake up version of the "signal" operation. + */ +int _POSIX_Condition_variables_Signal_support( + pthread_cond_t *cond, + bool is_broadcast +); + +/** + * @brief POSIX condition variables wait support. + * + * DESCRIPTION: + * + * A support routine which implements guts of the blocking, non-blocking, and + * timed wait version of condition variable wait routines. + */ +int _POSIX_Condition_variables_Wait_support( + pthread_cond_t *cond, + pthread_mutex_t *mutex, + Watchdog_Interval timeout, + bool already_timedout +); + +/* + * _POSIX_Condition_variables_Get + * + * DESCRIPTION: + * + * A support routine which translates the condition variable id into + * a local pointer. As a side-effect, it may create the condition + * variable. + */ + +POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get ( + pthread_cond_t *cond, + Objects_Locations *location +); + +/* + * _POSIX_Condition_variables_Allocate + */ + +RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control + *_POSIX_Condition_variables_Allocate( void ) +{ + return (POSIX_Condition_variables_Control *) + _Objects_Allocate( &_POSIX_Condition_variables_Information ); +} + +/* + * _POSIX_Condition_variables_Free + */ + +RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Free ( + POSIX_Condition_variables_Control *the_condition_variable +) +{ + _Objects_Free( + &_POSIX_Condition_variables_Information, + &the_condition_variable->Object + ); +} + +/* + * _POSIX_Condition_variables_Is_null + */ + +RTEMS_INLINE_ROUTINE bool _POSIX_Condition_variables_Is_null ( + POSIX_Condition_variables_Control *the_condition_variable +) +{ + return !the_condition_variable; +} + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/posix/inline/rtems/posix/cond.inl b/cpukit/posix/inline/rtems/posix/cond.inl deleted file mode 100644 index 914a69d07e..0000000000 --- a/cpukit/posix/inline/rtems/posix/cond.inl +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @file rtems/posix/cond.inl - * - * This include file contains the static inline implementation of the private - * inlined routines for POSIX condition variables. - */ - -/* - * 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_COND_H -# error "Never use directly; include instead." -#endif - -#ifndef _RTEMS_POSIX_COND_INL -#define _RTEMS_POSIX_COND_INL - -#include - -/* - * _POSIX_Condition_variables_Allocate - */ - -RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control - *_POSIX_Condition_variables_Allocate( void ) -{ - return (POSIX_Condition_variables_Control *) - _Objects_Allocate( &_POSIX_Condition_variables_Information ); -} - -/* - * _POSIX_Condition_variables_Free - */ - -RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Free ( - POSIX_Condition_variables_Control *the_condition_variable -) -{ - _Objects_Free( - &_POSIX_Condition_variables_Information, - &the_condition_variable->Object - ); -} - -/* - * _POSIX_Condition_variables_Is_null - */ - -RTEMS_INLINE_ROUTINE bool _POSIX_Condition_variables_Is_null ( - POSIX_Condition_variables_Control *the_condition_variable -) -{ - return !the_condition_variable; -} - -#endif -/* end of include file */ - diff --git a/cpukit/posix/preinstall.am b/cpukit/posix/preinstall.am index c84a54b1b9..21d2098a8b 100644 --- a/cpukit/posix/preinstall.am +++ b/cpukit/posix/preinstall.am @@ -52,6 +52,10 @@ $(PROJECT_INCLUDE)/rtems/posix/cond.h: include/rtems/posix/cond.h $(PROJECT_INCL $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/cond.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/cond.h +$(PROJECT_INCLUDE)/rtems/posix/condimpl.h: include/rtems/posix/condimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/condimpl.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/condimpl.h + $(PROJECT_INCLUDE)/rtems/posix/config.h: include/rtems/posix/config.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/config.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/config.h @@ -136,10 +140,6 @@ $(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/cond.inl: inline/rtems/posix/cond.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/cond.inl -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/cond.inl - $(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 diff --git a/cpukit/posix/src/barrierattrdestroy.c b/cpukit/posix/src/barrierattrdestroy.c index 1c2ed06116..76dca52d4d 100644 --- a/cpukit/posix/src/barrierattrdestroy.c +++ b/cpukit/posix/src/barrierattrdestroy.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/cond.c b/cpukit/posix/src/cond.c index 24bb4a440f..f35cfe1742 100644 --- a/cpukit/posix/src/cond.c +++ b/cpukit/posix/src/cond.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condattrdestroy.c b/cpukit/posix/src/condattrdestroy.c index 128138fcc6..485fb6958e 100644 --- a/cpukit/posix/src/condattrdestroy.c +++ b/cpukit/posix/src/condattrdestroy.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condattrgetpshared.c b/cpukit/posix/src/condattrgetpshared.c index e0868e1f86..5b7bcb098e 100644 --- a/cpukit/posix/src/condattrgetpshared.c +++ b/cpukit/posix/src/condattrgetpshared.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condattrinit.c b/cpukit/posix/src/condattrinit.c index 0d956c4398..188ec76be8 100644 --- a/cpukit/posix/src/condattrinit.c +++ b/cpukit/posix/src/condattrinit.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condattrsetpshared.c b/cpukit/posix/src/condattrsetpshared.c index 7ef820cf98..4aceb4940a 100644 --- a/cpukit/posix/src/condattrsetpshared.c +++ b/cpukit/posix/src/condattrsetpshared.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condbroadcast.c b/cpukit/posix/src/condbroadcast.c index f0bd905f05..207c07a721 100644 --- a/cpukit/posix/src/condbroadcast.c +++ b/cpukit/posix/src/condbroadcast.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/conddefaultattributes.c b/cpukit/posix/src/conddefaultattributes.c index 92c691f9a2..2f9bae3706 100644 --- a/cpukit/posix/src/conddefaultattributes.c +++ b/cpukit/posix/src/conddefaultattributes.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/conddestroy.c b/cpukit/posix/src/conddestroy.c index 161acbecf6..eff5ba0a13 100644 --- a/cpukit/posix/src/conddestroy.c +++ b/cpukit/posix/src/conddestroy.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condget.c b/cpukit/posix/src/condget.c index 4959d556d8..32bfa07a2a 100644 --- a/cpukit/posix/src/condget.c +++ b/cpukit/posix/src/condget.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condinit.c b/cpukit/posix/src/condinit.c index 3a16d8cdd4..ac77bdded4 100644 --- a/cpukit/posix/src/condinit.c +++ b/cpukit/posix/src/condinit.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condsignal.c b/cpukit/posix/src/condsignal.c index 02c9200642..0283fe45ea 100644 --- a/cpukit/posix/src/condsignal.c +++ b/cpukit/posix/src/condsignal.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condsignalsupp.c b/cpukit/posix/src/condsignalsupp.c index dae64948d8..5b29a08938 100644 --- a/cpukit/posix/src/condsignalsupp.c +++ b/cpukit/posix/src/condsignalsupp.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condtimedwait.c b/cpukit/posix/src/condtimedwait.c index 0ddeecfce8..787fd086c6 100644 --- a/cpukit/posix/src/condtimedwait.c +++ b/cpukit/posix/src/condtimedwait.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condwait.c b/cpukit/posix/src/condwait.c index e6382bf348..2120e3920c 100644 --- a/cpukit/posix/src/condwait.c +++ b/cpukit/posix/src/condwait.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c index b29010784f..690431aa43 100644 --- a/cpukit/posix/src/condwaitsupp.c +++ b/cpukit/posix/src/condwaitsupp.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/posix/src/rwlockattrdestroy.c b/cpukit/posix/src/rwlockattrdestroy.c index 9bc810c6e8..a8f719e11c 100644 --- a/cpukit/posix/src/rwlockattrdestroy.c +++ b/cpukit/posix/src/rwlockattrdestroy.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c index e6df58ae17..f2f138dc20 100644 --- a/cpukit/sapi/src/posixapi.c +++ b/cpukit/sapi/src/posixapi.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include -- cgit v1.2.3