From 047d67ab257600533bc3a1047a2a54d287dcc2d2 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 15 Nov 2006 14:08:49 +0000 Subject: 2006-11-15 Joel Sherrill * libcsupport/src/termios.c, posix/Makefile.am, posix/preinstall.am, posix/include/rtems/posix/config.h, posix/include/rtems/posix/time.h, sapi/src/posixapi.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/corerwlock.h, score/include/rtems/score/threadq.h, score/src/corerwlockobtainread.c, score/src/threadqenqueue.c, score/src/threadqtimeout.c: Adding POSIX barriers, POSIX spinlocks, and partial implementation of POSIX rwlocks. * posix/include/rtems/posix/barrier.h, posix/include/rtems/posix/rwlock.h, posix/include/rtems/posix/spinlock.h, posix/inline/rtems/posix/barrier.inl, posix/inline/rtems/posix/rwlock.inl, posix/inline/rtems/posix/spinlock.inl, posix/src/barrierattrdestroy.c, posix/src/barrierattrgetpshared.c, posix/src/barrierattrinit.c, posix/src/barrierattrsetpshared.c, posix/src/pbarrier.c, posix/src/pbarrierdestroy.c, posix/src/pbarrierinit.c, posix/src/pbarriertranslatereturncode.c, posix/src/pbarrierwait.c, posix/src/prwlock.c, posix/src/prwlockdestroy.c, posix/src/prwlockinit.c, posix/src/prwlockrdlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/prwlocktranslatereturncode.c, posix/src/prwlocktryrdlock.c, posix/src/prwlocktrywrlock.c, posix/src/prwlockunlock.c, posix/src/prwlockwrlock.c, posix/src/pspin.c, posix/src/pspindestroy.c, posix/src/pspininit.c, posix/src/pspinlock.c, posix/src/pspinlocktranslatereturncode.c, posix/src/pspintrylock.c, posix/src/pspinunlock.c, posix/src/rwlockattrdestroy.c, posix/src/rwlockattrgetpshared.c, posix/src/rwlockattrinit.c, posix/src/rwlockattrsetpshared.c: New files. --- cpukit/posix/inline/rtems/posix/barrier.inl | 85 ++++++++++++++++++++++++++++ cpukit/posix/inline/rtems/posix/rwlock.inl | 85 ++++++++++++++++++++++++++++ cpukit/posix/inline/rtems/posix/spinlock.inl | 85 ++++++++++++++++++++++++++++ 3 files changed, 255 insertions(+) create mode 100644 cpukit/posix/inline/rtems/posix/barrier.inl create mode 100644 cpukit/posix/inline/rtems/posix/rwlock.inl create mode 100644 cpukit/posix/inline/rtems/posix/spinlock.inl (limited to 'cpukit/posix/inline/rtems') diff --git a/cpukit/posix/inline/rtems/posix/barrier.inl b/cpukit/posix/inline/rtems/posix/barrier.inl new file mode 100644 index 0000000000..38cca3fb3f --- /dev/null +++ b/cpukit/posix/inline/rtems/posix/barrier.inl @@ -0,0 +1,85 @@ +/** + * @file rtems/posix/barrier.inl + */ + +/* + * This file contains the static inlin implementation of the inlined + * routines from the POSIX Barrier Manager. + * + * COPYRIGHT (c) 1989-2006. + * 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. + * + * $Id$ + */ + +#ifndef _RTEMS_POSIX_BARRIER_INL +#define _RTEMS_POSIX_BARRIER_INL + +#include + +/** + * @brief _POSIX_Barrier_Allocate + * + * This function allocates a barrier control block from + * the inactive chain of free barrier control blocks. + */ +RTEMS_INLINE_ROUTINE POSIX_Barrier_Control *_POSIX_Barrier_Allocate( void ) +{ + return (POSIX_Barrier_Control *) + _Objects_Allocate( &_POSIX_Barrier_Information ); +} + +/** + * @brief _POSIX_Barrier_Free + * + * This routine frees a barrier control block to the + * inactive chain of free barrier control blocks. + */ +RTEMS_INLINE_ROUTINE void _POSIX_Barrier_Free ( + POSIX_Barrier_Control *the_barrier +) +{ + _Objects_Free( &_POSIX_Barrier_Information, &the_barrier->Object ); +} + +/** + * @brief _POSIX_Barrier_Get + * + * This function maps barrier IDs to barrier control blocks. + * If ID corresponds to a local barrier, then it returns + * the_barrier control pointer which maps to ID and location + * is set to OBJECTS_LOCAL. if the barrier ID is global and + * resides on a remote node, then location is set to OBJECTS_REMOTE, + * and the_barrier is undefined. Otherwise, location is set + * to OBJECTS_ERROR and the_barrier is undefined. + */ +RTEMS_INLINE_ROUTINE POSIX_Barrier_Control *_POSIX_Barrier_Get ( + pthread_barrier_t *barrier, + Objects_Locations *location +) +{ + return (POSIX_Barrier_Control *) _Objects_Get( + &_POSIX_Barrier_Information, + *((Objects_Id *)barrier), + location + ); +} + +/** + * @brief _POSIX_Barrier_Is_null + * + * This function returns TRUE if the_barrier is NULL and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE boolean _POSIX_Barrier_Is_null ( + POSIX_Barrier_Control *the_barrier +) +{ + return ( the_barrier == NULL ); +} + +#endif +/* end of include file */ diff --git a/cpukit/posix/inline/rtems/posix/rwlock.inl b/cpukit/posix/inline/rtems/posix/rwlock.inl new file mode 100644 index 0000000000..79d13a66cf --- /dev/null +++ b/cpukit/posix/inline/rtems/posix/rwlock.inl @@ -0,0 +1,85 @@ +/** + * @file rtems/posix/RWLock.inl + */ + +/* + * This file contains the static inlin implementation of the inlined + * routines from the POSIX RWLock Manager. + * + * COPYRIGHT (c) 1989-2006. + * 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. + * + * $Id$ + */ + +#ifndef _RTEMS_POSIX_RWLOCK_INL +#define _RTEMS_POSIX_RWLOCK_INL + +#include + +/** + * @brief _POSIX_RWLock_Allocate + * + * 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 _POSIX_RWLock_Free + * + * 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 _POSIX_RWLock_Get + * + * 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 _POSIX_RWLock_Is_null + * + * This function returns TRUE if the_RWLock is NULL and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE boolean _POSIX_RWLock_Is_null ( + POSIX_RWLock_Control *the_RWLock +) +{ + return ( the_RWLock == NULL ); +} + +#endif +/* end of include file */ diff --git a/cpukit/posix/inline/rtems/posix/spinlock.inl b/cpukit/posix/inline/rtems/posix/spinlock.inl new file mode 100644 index 0000000000..1f33a29759 --- /dev/null +++ b/cpukit/posix/inline/rtems/posix/spinlock.inl @@ -0,0 +1,85 @@ +/** + * @file rtems/posix/spinlock.inl + */ + +/* + * This file contains the static inlin implementation of the inlined + * routines from the POSIX Spinlock Manager. + * + * COPYRIGHT (c) 1989-2006. + * 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. + * + * $Id$ + */ + +#ifndef _RTEMS_POSIX_SPINLOCK_INL +#define _RTEMS_POSIX_SPINLOCK_INL + +#include + +/** + * @brief _POSIX_Spinlock_Allocate + * + * 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 _POSIX_Spinlock_Free + * + * 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 _POSIX_Spinlock_Get + * + * 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 _POSIX_Spinlock_Is_null + * + * This function returns TRUE if the_spinlock is NULL and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE boolean _POSIX_Spinlock_Is_null ( + POSIX_Spinlock_Control *the_spinlock +) +{ + return ( the_spinlock == NULL ); +} + +#endif +/* end of include file */ -- cgit v1.2.3