summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2006-11-15 14:08:49 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2006-11-15 14:08:49 +0000
commit047d67ab257600533bc3a1047a2a54d287dcc2d2 (patch)
tree1fc509d0e86d7998aa162912bb9c3d01a7606fed /cpukit/posix
parentRegenerate. (diff)
downloadrtems-047d67ab257600533bc3a1047a2a54d287dcc2d2.tar.bz2
2006-11-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* 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.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/Makefile.am25
-rw-r--r--cpukit/posix/include/rtems/posix/barrier.h90
-rw-r--r--cpukit/posix/include/rtems/posix/config.h3
-rw-r--r--cpukit/posix/include/rtems/posix/rwlock.h90
-rw-r--r--cpukit/posix/include/rtems/posix/spinlock.h90
-rw-r--r--cpukit/posix/include/rtems/posix/time.h14
-rw-r--r--cpukit/posix/inline/rtems/posix/barrier.inl85
-rw-r--r--cpukit/posix/inline/rtems/posix/rwlock.inl85
-rw-r--r--cpukit/posix/inline/rtems/posix/spinlock.inl85
-rw-r--r--cpukit/posix/preinstall.am25
-rw-r--r--cpukit/posix/src/barrierattrdestroy.c34
-rw-r--r--cpukit/posix/src/barrierattrgetpshared.c30
-rw-r--r--cpukit/posix/src/barrierattrinit.c29
-rw-r--r--cpukit/posix/src/barrierattrsetpshared.c37
-rw-r--r--cpukit/posix/src/pbarrier.c60
-rw-r--r--cpukit/posix/src/pbarrierdestroy.c71
-rw-r--r--cpukit/posix/src/pbarrierinit.c94
-rw-r--r--cpukit/posix/src/pbarriertranslatereturncode.c51
-rw-r--r--cpukit/posix/src/pbarrierwait.c68
-rw-r--r--cpukit/posix/src/prwlock.c48
-rw-r--r--cpukit/posix/src/prwlockdestroy.c73
-rw-r--r--cpukit/posix/src/prwlockinit.c90
-rw-r--r--cpukit/posix/src/prwlockrdlock.c71
-rw-r--r--cpukit/posix/src/prwlocktimedrdlock.c79
-rw-r--r--cpukit/posix/src/prwlocktimedwrlock.c79
-rw-r--r--cpukit/posix/src/prwlocktranslatereturncode.c51
-rw-r--r--cpukit/posix/src/prwlocktryrdlock.c72
-rw-r--r--cpukit/posix/src/prwlocktrywrlock.c71
-rw-r--r--cpukit/posix/src/prwlockunlock.c63
-rw-r--r--cpukit/posix/src/prwlockwrlock.c71
-rw-r--r--cpukit/posix/src/pspin.c60
-rw-r--r--cpukit/posix/src/pspindestroy.c71
-rw-r--r--cpukit/posix/src/pspininit.c80
-rw-r--r--cpukit/posix/src/pspinlock.c60
-rw-r--r--cpukit/posix/src/pspinlocktranslatereturncode.c53
-rw-r--r--cpukit/posix/src/pspintrylock.c60
-rw-r--r--cpukit/posix/src/pspinunlock.c60
-rw-r--r--cpukit/posix/src/rwlockattrdestroy.c34
-rw-r--r--cpukit/posix/src/rwlockattrgetpshared.c30
-rw-r--r--cpukit/posix/src/rwlockattrinit.c29
-rw-r--r--cpukit/posix/src/rwlockattrsetpshared.c37
41 files changed, 2402 insertions, 6 deletions
diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am
index cdcb69ebdb..49f86640c7 100644
--- a/cpukit/posix/Makefile.am
+++ b/cpukit/posix/Makefile.am
@@ -25,7 +25,8 @@ include_rtems_posix_HEADERS = include/rtems/posix/cancel.h \
include/rtems/posix/priority.h include/rtems/posix/psignal.h \
include/rtems/posix/pthread.h include/rtems/posix/semaphore.h \
include/rtems/posix/threadsup.h include/rtems/posix/time.h \
- include/rtems/posix/timer.h
+ include/rtems/posix/timer.h include/rtems/posix/barrier.h \
+ include/rtems/posix/rwlock.h include/rtems/posix/spinlock.h
if HAS_MP
include_rtems_posix_HEADERS += include/rtems/posix/condmp.h \
@@ -37,7 +38,8 @@ include_rtems_posix_HEADERS += inline/rtems/posix/cond.inl \
inline/rtems/posix/key.inl inline/rtems/posix/mqueue.inl \
inline/rtems/posix/mutex.inl inline/rtems/posix/pthread.inl \
inline/rtems/posix/priority.inl inline/rtems/posix/semaphore.inl \
- inline/rtems/posix/timer.inl
+ inline/rtems/posix/timer.inl inline/rtems/posix/barrier.inl \
+ inline/rtems/posix/rwlock.inl inline/rtems/posix/spinlock.inl
## src
@@ -50,6 +52,12 @@ libposix_a_SOURCES += src/execl.c src/execle.c src/execlp.c src/execv.c \
src/execve.c src/execvp.c src/fork.c src/pthreadatfork.c src/wait.c \
src/waitpid.c
+## BARRIER_C_FILES
+libposix_a_SOURCES += src/barrierattrdestroy.c src/barrierattrgetpshared.c \
+ src/barrierattrinit.c src/barrierattrsetpshared.c src/pbarrier.c \
+ src/pbarrierdestroy.c src/pbarrierinit.c \
+ src/pbarriertranslatereturncode.c src/pbarrierwait.c
+
## CANCEL_C_FILES
libposix_a_SOURCES += src/cancel.c src/cancelrun.c src/cleanuppop.c \
src/cleanuppush.c src/setcancelstate.c src/setcanceltype.c \
@@ -115,6 +123,14 @@ libposix_a_SOURCES += src/psignal.c src/alarm.c src/kill.c src/killinfo.c \
src/sigprocmask.c src/sigqueue.c src/sigsuspend.c src/sigtimedwait.c \
src/sigwait.c src/sigwaitinfo.c src/signal_2.c src/ualarm.c
+## RWLOCK_C_FILES
+libposix_a_SOURCES += src/prwlock.c src/prwlockdestroy.c src/prwlockinit.c \
+ src/prwlockrdlock.c src/prwlocktimedrdlock.c src/prwlocktimedwrlock.c \
+ src/prwlocktryrdlock.c src/prwlocktrywrlock.c src/prwlockunlock.c \
+ src/prwlockwrlock.c src/rwlockattrdestroy.c src/rwlockattrgetpshared.c \
+ src/rwlockattrinit.c src/rwlockattrsetpshared.c \
+ src/prwlocktranslatereturncode.c
+
## SEMAPHORE_C_FILES
libposix_a_SOURCES += src/semaphore.c src/semaphorecreatesupp.c \
src/semaphoredeletesupp.c src/semaphoremp.c src/semaphorenametoid.c \
@@ -122,6 +138,11 @@ libposix_a_SOURCES += src/semaphore.c src/semaphorecreatesupp.c \
src/semgetvalue.c src/seminit.c src/semopen.c src/sempost.c \
src/semtimedwait.c src/semtrywait.c src/semunlink.c src/semwait.c
+## SPINLOCK_C_FILES
+libposix_a_SOURCES += src/pspin.c src/pspindestroy.c src/pspininit.c \
+ src/pspinlock.c src/pspinlocktranslatereturncode.c src/pspintrylock.c \
+ src/pspinunlock.c
+
## TIME_C_FILES
libposix_a_SOURCES += src/adjtime.c src/time.c src/posixtimespecsubtract.c \
src/posixtimespectointerval.c src/posixintervaltotimespec.c \
diff --git a/cpukit/posix/include/rtems/posix/barrier.h b/cpukit/posix/include/rtems/posix/barrier.h
new file mode 100644
index 0000000000..abbcc1bc41
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/barrier.h
@@ -0,0 +1,90 @@
+/**
+ * @file rtems/posix/barrier.h
+ */
+
+/*
+ * This include file contains all the constants and structures associated
+ * with the POSIX Barrier Manager.
+ *
+ * Directives provided are:
+ *
+ * + create a barrier
+ * + delete a barrier
+ * + wait for a barrier
+ *
+ * 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_H
+#define _RTEMS_POSIX_BARRIER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/score/object.h>
+#include <rtems/score/corebarrier.h>
+
+/**
+ * This type defines the control block used to manage each barrier.
+ */
+
+typedef struct {
+ /** This is used to manage a barrier as an object. */
+ Objects_Control Object;
+ /** This is used to implement the barrier. */
+ CORE_barrier_Control Barrier;
+} POSIX_Barrier_Control;
+
+/**
+ * The following defines the information control block used to manage
+ * this class of objects.
+ */
+
+POSIX_EXTERN Objects_Information _POSIX_Barrier_Information;
+
+/**
+ * @brief _POSIX_Barrier_Manager_initialization
+ *
+ * This routine performs the initialization necessary for this manager.
+ *
+ * @param[in] maximum_barriers is the total number of barriers allowed to
+ * concurrently be active in the system.
+ */
+
+void _POSIX_Barrier_Manager_initialization(
+ uint32_t maximum_barriers
+);
+
+/**
+ * @brief _POSIX_Barrier_Translate_core_barrier_return_code (
+ *
+ * This routine translates SuperCore Barrier status codes into the
+ * corresponding POSIX ones.
+ *
+ *
+ * @param[in] the_barrier_status is the SuperCore status.
+ *
+ * @return the corresponding POSIX status
+ */
+int _POSIX_Barrier_Translate_core_barrier_return_code(
+ CORE_barrier_Status the_barrier_status
+);
+
+#ifndef __RTEMS_APPLICATION__
+#include <rtems/posix/barrier.inl>
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/posix/include/rtems/posix/config.h b/cpukit/posix/include/rtems/posix/config.h
index 6364003825..669c6151dd 100644
--- a/cpukit/posix/include/rtems/posix/config.h
+++ b/cpukit/posix/include/rtems/posix/config.h
@@ -54,6 +54,9 @@ typedef struct {
int maximum_queued_signals;
int maximum_message_queues;
int maximum_semaphores;
+ int maximum_barriers;
+ int maximum_rwlocks;
+ int maximum_spinlocks;
int number_of_initialization_threads;
posix_initialization_threads_table *User_initialization_threads_table;
} posix_api_configuration_table;
diff --git a/cpukit/posix/include/rtems/posix/rwlock.h b/cpukit/posix/include/rtems/posix/rwlock.h
new file mode 100644
index 0000000000..ae80df68a9
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/rwlock.h
@@ -0,0 +1,90 @@
+/**
+ * @file rtems/posix/rwlock.h
+ */
+
+/*
+ * This include file contains all the constants and structures associated
+ * with the POSIX RWLock Manager.
+ *
+ * Directives provided are:
+ *
+ * + create a RWLock
+ * + delete a RWLock
+ * + wait for a RWLock
+ *
+ * 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_H
+#define _RTEMS_POSIX_RWLOCK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/score/object.h>
+#include <rtems/score/corerwlock.h>
+
+/**
+ * This type defines the control block used to manage each RWLock.
+ */
+
+typedef struct {
+ /** This is used to manage a RWLock as an object. */
+ Objects_Control Object;
+ /** This is used to implement the RWLock. */
+ CORE_RWLock_Control RWLock;
+} POSIX_RWLock_Control;
+
+/**
+ * The following defines the information control block used to manage
+ * this class of objects.
+ */
+
+POSIX_EXTERN Objects_Information _POSIX_RWLock_Information;
+
+/**
+ * @brief _POSIX_RWLock_Manager_initialization
+ *
+ * This routine performs the initialization necessary for this manager.
+ *
+ * @param[in] maximum_rwlocks is the total number of RWLocks allowed to
+ * concurrently be active in the system.
+ */
+
+void _POSIX_RWLock_Manager_initialization(
+ uint32_t maximum_rwlocks
+);
+
+/**
+ * @brief _POSIX_RWLock_Translate_core_RWLock_return_code (
+ *
+ * This routine translates SuperCore RWLock status codes into the
+ * corresponding POSIX ones.
+ *
+ *
+ * @param[in] the_RWLock_status is the SuperCore status.
+ *
+ * @return the corresponding POSIX status
+ */
+int _POSIX_RWLock_Translate_core_RWLock_return_code(
+ CORE_RWLock_Status the_RWLock_status
+);
+
+#ifndef __RTEMS_APPLICATION__
+#include <rtems/posix/rwlock.inl>
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/posix/include/rtems/posix/spinlock.h b/cpukit/posix/include/rtems/posix/spinlock.h
new file mode 100644
index 0000000000..8d4517fac8
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/spinlock.h
@@ -0,0 +1,90 @@
+/**
+ * @file rtems/posix/spinlock.h
+ */
+
+/*
+ * This include file contains all the constants and structures associated
+ * with the POSIX Spinlock Manager.
+ *
+ * Directives provided are:
+ *
+ * + create a spinlock
+ * + delete a spinlock
+ * + wait for a spinlock
+ *
+ * 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_H
+#define _RTEMS_POSIX_SPINLOCK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/score/object.h>
+#include <rtems/score/corespinlock.h>
+
+/**
+ * This type defines the control block used to manage each spinlock.
+ */
+
+typedef struct {
+ /** This is used to manage a spinlock as an object. */
+ Objects_Control Object;
+ /** This is used to implement the spinlock. */
+ 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.
+ *
+ * @param[in] maximum_spinlocks is the total number of spinlocks allowed to
+ * concurrently be active in the system.
+ */
+
+void _POSIX_Spinlock_Manager_initialization(
+ uint32_t maximum_spinlocks
+);
+
+/**
+ * @brief _POSIX_Spinlock_Translate_core_spinlock_return_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 <rtems/posix/spinlock.inl>
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/posix/include/rtems/posix/time.h b/cpukit/posix/include/rtems/posix/time.h
index 13418cf473..76fe4216a4 100644
--- a/cpukit/posix/include/rtems/posix/time.h
+++ b/cpukit/posix/include/rtems/posix/time.h
@@ -22,8 +22,7 @@
(((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
(4 * TOD_SECONDS_PER_DAY))
-/*PAGE
- *
+/*
* _POSIX_Timespec_subtract
*/
@@ -41,8 +40,7 @@ Watchdog_Interval _POSIX_Timespec_to_interval(
const struct timespec *time
);
-/*PAGE
- *
+/*
* _POSIX_Interval_to_timespec
*/
@@ -51,4 +49,12 @@ void _POSIX_Interval_to_timespec(
struct timespec *time
);
+/*
+ * _POSIX_Absolute_timeout_to_ticks
+ */
+int _POSIX_Absolute_timeout_to_ticks(
+ const struct timespec *abstime,
+ Watchdog_Interval *ticks_out
+);
+
#endif
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 <pthread.h>
+
+/**
+ * @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 <pthread.h>
+
+/**
+ * @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 <pthread.h>
+
+/**
+ * @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 */
diff --git a/cpukit/posix/preinstall.am b/cpukit/posix/preinstall.am
index 2f7a86bca8..2782d196da 100644
--- a/cpukit/posix/preinstall.am
+++ b/cpukit/posix/preinstall.am
@@ -44,6 +44,10 @@ $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp):
@: > $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+$(PROJECT_INCLUDE)/rtems/posix/barrier.h: include/rtems/posix/barrier.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/barrier.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/barrier.h
+
$(PROJECT_INCLUDE)/rtems/posix/cancel.h: include/rtems/posix/cancel.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/cancel.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/cancel.h
@@ -84,10 +88,18 @@ $(PROJECT_INCLUDE)/rtems/posix/pthread.h: include/rtems/posix/pthread.h $(PROJEC
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/pthread.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/pthread.h
+$(PROJECT_INCLUDE)/rtems/posix/rwlock.h: include/rtems/posix/rwlock.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/rwlock.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/rwlock.h
+
$(PROJECT_INCLUDE)/rtems/posix/semaphore.h: include/rtems/posix/semaphore.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/semaphore.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/semaphore.h
+$(PROJECT_INCLUDE)/rtems/posix/spinlock.h: include/rtems/posix/spinlock.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/spinlock.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/spinlock.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
@@ -121,6 +133,11 @@ $(PROJECT_INCLUDE)/rtems/posix/semaphoremp.h: include/rtems/posix/semaphoremp.h
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/semaphoremp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/semaphoremp.h
endif
+
+$(PROJECT_INCLUDE)/rtems/posix/barrier.inl: inline/rtems/posix/barrier.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/barrier.inl
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/barrier.inl
+
$(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
@@ -145,10 +162,18 @@ $(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/rwlock.inl: inline/rtems/posix/rwlock.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/rwlock.inl
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/rwlock.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/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
+
$(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/barrierattrdestroy.c b/cpukit/posix/src/barrierattrdestroy.c
new file mode 100644
index 0000000000..7b34b1c2ec
--- /dev/null
+++ b/cpukit/posix/src/barrierattrdestroy.c
@@ -0,0 +1,34 @@
+/*
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/score/object.h>
+#include <rtems/score/states.h>
+#include <rtems/score/watchdog.h>
+#include <rtems/posix/cond.h>
+#include <rtems/posix/time.h>
+#include <rtems/posix/mutex.h>
+
+/*PAGE
+ *
+ * Barrier Initialization Attributes
+ */
+
+int pthread_barrierattr_destroy(
+ pthread_barrierattr_t *attr
+)
+{
+ if ( !attr || attr->is_initialized == FALSE )
+ return EINVAL;
+
+ attr->is_initialized = FALSE;
+ return 0;
+}
diff --git a/cpukit/posix/src/barrierattrgetpshared.c b/cpukit/posix/src/barrierattrgetpshared.c
new file mode 100644
index 0000000000..52fadb2d08
--- /dev/null
+++ b/cpukit/posix/src/barrierattrgetpshared.c
@@ -0,0 +1,30 @@
+/*
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+/*PAGE
+ *
+ * Barrier Attributes Get Process Shared
+ */
+
+int pthread_barrierattr_getpshared(
+ const pthread_barrierattr_t *attr,
+ int *pshared
+)
+{
+ if ( !attr )
+ return EINVAL;
+
+ if ( !attr->is_initialized )
+ return EINVAL;
+
+ *pshared = attr->process_shared;
+ return 0;
+}
diff --git a/cpukit/posix/src/barrierattrinit.c b/cpukit/posix/src/barrierattrinit.c
new file mode 100644
index 0000000000..ec7a036cf4
--- /dev/null
+++ b/cpukit/posix/src/barrierattrinit.c
@@ -0,0 +1,29 @@
+/*
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+
+/*PAGE
+ *
+ * Barrier Attributes Initialization
+ */
+
+int pthread_barrierattr_init(
+ pthread_barrierattr_t *attr
+)
+{
+ if ( !attr )
+ return EINVAL;
+
+ attr->is_initialized = TRUE;
+ attr->process_shared = PTHREAD_PROCESS_PRIVATE;
+ return 0;
+}
diff --git a/cpukit/posix/src/barrierattrsetpshared.c b/cpukit/posix/src/barrierattrsetpshared.c
new file mode 100644
index 0000000000..e7d226ea1a
--- /dev/null
+++ b/cpukit/posix/src/barrierattrsetpshared.c
@@ -0,0 +1,37 @@
+/*
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+/*PAGE
+ *
+ * Barrier Attributes Set Process Shared
+ */
+
+int pthread_barrierattr_setpshared(
+ pthread_barrierattr_t *attr,
+ int pshared
+)
+{
+ if ( !attr )
+ return EINVAL;
+
+ if ( !attr->is_initialized )
+ return EINVAL;
+
+ switch ( pshared ) {
+ case PTHREAD_PROCESS_SHARED:
+ case PTHREAD_PROCESS_PRIVATE:
+ attr->process_shared = pshared;
+ return 0;
+
+ default:
+ return EINVAL;
+ }
+}
diff --git a/cpukit/posix/src/pbarrier.c b/cpukit/posix/src/pbarrier.c
new file mode 100644
index 0000000000..1b1c285b09
--- /dev/null
+++ b/cpukit/posix/src/pbarrier.c
@@ -0,0 +1,60 @@
+/*
+ * Barrier Manager
+ *
+ * DESCRIPTION:
+ *
+ * This package is the implementation of the Barrier Manager.
+ *
+ * Directives provided are:
+ *
+ * + create a barrier
+ * + get an ID of a barrier
+ * + delete a barrier
+ * + acquire a barrier
+ * + release a barrier
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/posix/barrier.h>
+
+/**
+ * @brief _POSIX_Barrier_Manager_initialization
+ *
+ * Input parameters:
+ * maximum_barriers - maximum configured barriers
+ *
+ * Output parameters: NONE
+ */
+
+void _POSIX_Barrier_Manager_initialization(
+ uint32_t maximum_barriers
+)
+{
+ _Objects_Initialize_information(
+ &_POSIX_Barrier_Information, /* object information table */
+ OBJECTS_POSIX_API, /* object API */
+ OBJECTS_POSIX_BARRIERS, /* object class */
+ maximum_barriers, /* maximum objects of this class */
+ sizeof( POSIX_Barrier_Control ),/* size of this object's control block */
+ FALSE, /* TRUE if the name is a string */
+ 0 /* maximum length of an object name */
+#if defined(RTEMS_MULTIPROCESSING)
+ ,
+ FALSE, /* TRUE if this is a global object class */
+ NULL /* Proxy extraction support callout */
+#endif
+ );
+}
diff --git a/cpukit/posix/src/pbarrierdestroy.c b/cpukit/posix/src/pbarrierdestroy.c
new file mode 100644
index 0000000000..ed48e78b55
--- /dev/null
+++ b/cpukit/posix/src/pbarrierdestroy.c
@@ -0,0 +1,71 @@
+/*
+ * POSIX Barrier Manager -- Destroy a Barrier
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/barrier.h>
+
+/*
+ * pthread_barrier_destroy
+ *
+ * This directive allows a thread to delete a barrier specified by
+ * the barrier id. The barrier is freed back to the inactive
+ * barrier chain.
+ *
+ * Input parameters:
+ * barrier - barrier id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_barrier_destroy(
+ pthread_barrier_t *barrier
+)
+{
+ POSIX_Barrier_Control *the_barrier = NULL;
+ Objects_Locations location;
+
+ if ( !barrier )
+ return EINVAL;
+
+ the_barrier = _POSIX_Barrier_Get( barrier, &location );
+ switch ( location ) {
+
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+ if ( the_barrier->Barrier.number_of_waiting_threads != 0 ) {
+ _Thread_Enable_dispatch();
+ return EBUSY;
+ }
+
+ _Objects_Close( &_POSIX_Barrier_Information, &the_barrier->Object );
+
+ _POSIX_Barrier_Free( the_barrier );
+
+ _Thread_Enable_dispatch();
+ return 0;
+ }
+
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/pbarrierinit.c b/cpukit/posix/src/pbarrierinit.c
new file mode 100644
index 0000000000..408964cfed
--- /dev/null
+++ b/cpukit/posix/src/pbarrierinit.c
@@ -0,0 +1,94 @@
+/*
+ * POSIX Barrier Manager -- Initialize a Barrier Instance
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/barrier.h>
+
+/*
+ * pthread_barrier_init
+ *
+ * This directive creates a barrier. A barrier id is returned.
+ *
+ * Input parameters:
+ * barrier - pointer to barrier id
+ * attr - barrier attributes
+ * count - number of threads before automatic release
+ *
+ * Output parameters:
+ * barrier - barrier id
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_barrier_init(
+ pthread_barrier_t *barrier,
+ const pthread_barrierattr_t *attr,
+ unsigned int count
+)
+{
+ POSIX_Barrier_Control *the_barrier;
+ CORE_barrier_Attributes the_attributes;
+
+
+ if ( !barrier )
+ return EINVAL;
+
+ if ( count == 0 )
+ return EINVAL;
+
+ if ( !attr )
+ return EINVAL;
+
+ if ( !attr->is_initialized )
+ return EINVAL;
+
+ switch ( attr->process_shared ) {
+ case PTHREAD_PROCESS_PRIVATE: /* only supported values */
+ break;
+ case PTHREAD_PROCESS_SHARED:
+ default:
+ return EINVAL;
+ }
+
+ the_attributes.discipline = CORE_BARRIER_AUTOMATIC_RELEASE;
+ the_attributes.maximum_count = count;
+
+ _Thread_Disable_dispatch(); /* prevents deletion */
+
+ the_barrier = _POSIX_Barrier_Allocate();
+
+ if ( !the_barrier ) {
+ _Thread_Enable_dispatch();
+ return EAGAIN;
+ }
+
+ _CORE_barrier_Initialize( &the_barrier->Barrier, &the_attributes );
+
+ _Objects_Open(
+ &_POSIX_Barrier_Information,
+ &the_barrier->Object,
+ 0
+ );
+
+ *barrier = the_barrier->Object.id;
+
+ _Thread_Enable_dispatch();
+ return 0;
+}
diff --git a/cpukit/posix/src/pbarriertranslatereturncode.c b/cpukit/posix/src/pbarriertranslatereturncode.c
new file mode 100644
index 0000000000..d7dc607bc3
--- /dev/null
+++ b/cpukit/posix/src/pbarriertranslatereturncode.c
@@ -0,0 +1,51 @@
+/*
+ * Barrier Manager -- Translate SuperCore Status
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/barrier.h>
+
+/*
+ * _POSIX_Barrier_Translate_core_barrier_return_code
+ *
+ * Input parameters:
+ * the_barrier_status - barrier status code to translate
+ *
+ * Output parameters:
+ * status code - translated POSIX status code
+ *
+ */
+
+static int _POSIX_Barrier_Return_codes[] = {
+ 0, /* CORE_BARRIER_STATUS_SUCCESSFUL */
+ PTHREAD_BARRIER_SERIAL_THREAD,
+ /* CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED */
+ -1, /* CORE_BARRIER_WAS_DELETED */
+ 0 /* CORE_BARRIER_TIMEOUT */
+};
+
+
+int _POSIX_Barrier_Translate_core_barrier_return_code(
+ CORE_barrier_Status the_barrier_status
+)
+{
+ if ( the_barrier_status <= CORE_BARRIER_TIMEOUT )
+ return _POSIX_Barrier_Return_codes[the_barrier_status];
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/pbarrierwait.c b/cpukit/posix/src/pbarrierwait.c
new file mode 100644
index 0000000000..8856274fe6
--- /dev/null
+++ b/cpukit/posix/src/pbarrierwait.c
@@ -0,0 +1,68 @@
+/*
+ * POSIX Barrier Manager -- Wait at a Barrier
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/barrier.h>
+
+/*
+ * pthread_barrier_wait
+ *
+ * This directive allows a thread to wait at a barrier.
+ *
+ * Input parameters:
+ * barrier - barrier id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * PTHREAD_BARRIER_SERIAL_THREAD - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_barrier_wait(
+ pthread_barrier_t *barrier
+)
+{
+ POSIX_Barrier_Control *the_barrier = NULL;
+ Objects_Locations location;
+
+ if ( !barrier )
+ return EINVAL;
+
+ the_barrier = _POSIX_Barrier_Get( barrier, &location );
+ switch ( location ) {
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+ _CORE_barrier_Wait(
+ &the_barrier->Barrier,
+ the_barrier->Object.id,
+ TRUE,
+ 0,
+ NULL
+ );
+ _Thread_Enable_dispatch();
+ return _POSIX_Barrier_Translate_core_barrier_return_code(
+ _Thread_Executing->Wait.return_code );
+
+ }
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/prwlock.c b/cpukit/posix/src/prwlock.c
new file mode 100644
index 0000000000..37197a88b0
--- /dev/null
+++ b/cpukit/posix/src/prwlock.c
@@ -0,0 +1,48 @@
+/*
+ * RWLock Manager -- Initialization
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/posix/rwlock.h>
+
+/**
+ * @brief _POSIX_RWLock_Manager_initialization
+ *
+ * Input parameters:
+ * maximum_rwlocks - maximum configured rwlocks
+ *
+ * Output parameters: NONE
+ */
+
+void _POSIX_RWLock_Manager_initialization(
+ uint32_t maximum_rwlocks
+)
+{
+ _Objects_Initialize_information(
+ &_POSIX_RWLock_Information, /* object information table */
+ OBJECTS_POSIX_API, /* object API */
+ OBJECTS_POSIX_SPINLOCKS, /* object class */
+ maximum_rwlocks, /* maximum objects of this class */
+ sizeof( POSIX_RWLock_Control ), /* size of this object's control block */
+ FALSE, /* TRUE if the name is a string */
+ 0 /* maximum length of an object name */
+#if defined(RTEMS_MULTIPROCESSING)
+ ,
+ FALSE, /* TRUE if this is a global object class */
+ NULL /* Proxy extraction support callout */
+#endif
+ );
+}
diff --git a/cpukit/posix/src/prwlockdestroy.c b/cpukit/posix/src/prwlockdestroy.c
new file mode 100644
index 0000000000..6ba858d1d9
--- /dev/null
+++ b/cpukit/posix/src/prwlockdestroy.c
@@ -0,0 +1,73 @@
+/*
+ * POSIX RWLock Manager -- Destroy a RWLock
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/rwlock.h>
+
+/*
+ * pthread_rwlock_destroy
+ *
+ * This directive allows a thread to delete a rwlock specified by
+ * the rwlock id. The rwlock is freed back to the inactive
+ * rwlock chain.
+ *
+ * Input parameters:
+ * rwlock - rwlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_rwlock_destroy(
+ pthread_rwlock_t *rwlock
+)
+{
+ POSIX_RWLock_Control *the_rwlock = NULL;
+ Objects_Locations location;
+
+ if ( !rwlock )
+ return EINVAL;
+
+ the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
+ switch ( location ) {
+
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+#if 0
+ if ( the_rwlock->RWLock.number_of_waiting_threads != 0 ) {
+ _Thread_Enable_dispatch();
+ return EBUSY;
+ }
+#endif
+
+ _Objects_Close( &_POSIX_RWLock_Information, &the_rwlock->Object );
+
+ _POSIX_RWLock_Free( the_rwlock );
+
+ _Thread_Enable_dispatch();
+ return 0;
+ }
+
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/prwlockinit.c b/cpukit/posix/src/prwlockinit.c
new file mode 100644
index 0000000000..6d6fe1a2c4
--- /dev/null
+++ b/cpukit/posix/src/prwlockinit.c
@@ -0,0 +1,90 @@
+/*
+ * POSIX RWLock Manager -- Destroy a RWLock Instance
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/rwlock.h>
+
+/*
+ * pthread_rwlock_init
+ *
+ * This directive creates a rwlock. A rwlock id is returned.
+ *
+ * Input parameters:
+ * rwlock - pointer to rwlock id
+ * attr - rwlock attributes
+ *
+ * Output parameters:
+ * rwlock - rwlock id
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_rwlock_init(
+ pthread_rwlock_t *rwlock,
+ const pthread_rwlockattr_t *attr
+)
+{
+ POSIX_RWLock_Control *the_rwlock;
+ CORE_RWLock_Attributes the_attributes;
+
+
+ if ( !rwlock )
+ return EINVAL;
+
+ if ( !attr )
+ return EINVAL;
+
+ if ( !attr->is_initialized )
+ return EINVAL;
+
+ switch ( attr->process_shared ) {
+ case PTHREAD_PROCESS_PRIVATE: /* only supported values */
+ break;
+ case PTHREAD_PROCESS_SHARED:
+ default:
+ return EINVAL;
+ }
+
+/*
+ the_attributes.discipline = CORE_RWLOCK_AUTOMATIC_RELEASE;
+*/
+
+ _Thread_Disable_dispatch(); /* prevents deletion */
+
+ the_rwlock = _POSIX_RWLock_Allocate();
+
+ if ( !the_rwlock ) {
+ _Thread_Enable_dispatch();
+ return EAGAIN;
+ }
+
+ _CORE_RWLock_Initialize( &the_rwlock->RWLock, &the_attributes );
+
+ _Objects_Open(
+ &_POSIX_RWLock_Information,
+ &the_rwlock->Object,
+ 0
+ );
+
+ *rwlock = the_rwlock->Object.id;
+
+ _Thread_Enable_dispatch();
+ return 0;
+}
diff --git a/cpukit/posix/src/prwlockrdlock.c b/cpukit/posix/src/prwlockrdlock.c
new file mode 100644
index 0000000000..adc5130181
--- /dev/null
+++ b/cpukit/posix/src/prwlockrdlock.c
@@ -0,0 +1,71 @@
+/*
+ * POSIX RWLock Manager -- Obtain a Read Lock on a RWLock Instance
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/rwlock.h>
+
+/*
+ * pthread_rwlock_rdlock
+ *
+ * This directive attempts to obtain a read only lock on an rwlock instance.
+ *
+ * Input parameters:
+ * rwlock - pointer to rwlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_rwlock_rdlock(
+ pthread_rwlock_t *rwlock
+)
+{
+ POSIX_RWLock_Control *the_rwlock;
+ Objects_Locations location;
+
+ if ( !rwlock )
+ return EINVAL;
+
+ the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
+ switch ( location ) {
+
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+
+ _CORE_RWLock_Obtain_for_reading(
+ &the_rwlock->RWLock,
+ *rwlock,
+ TRUE, // we are willing to wait forever
+ 0,
+ NULL
+ );
+
+ _Thread_Enable_dispatch();
+ return _POSIX_RWLock_Translate_core_RWLock_return_code(
+ (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
+ );
+ }
+
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/prwlocktimedrdlock.c b/cpukit/posix/src/prwlocktimedrdlock.c
new file mode 100644
index 0000000000..2e9d578018
--- /dev/null
+++ b/cpukit/posix/src/prwlocktimedrdlock.c
@@ -0,0 +1,79 @@
+/*
+ * POSIX RWLock Manager -- Attempt to Obtain a Read Lock on a RWLock Instance
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/rwlock.h>
+#include <rtems/posix/time.h>
+
+/*
+ * pthread_rwlock_timedrdlock
+ *
+ * This directive attempts to obtain a read only lock on an rwlock instance.
+ *
+ * Input parameters:
+ * rwlock - pointer to rwlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_rwlock_timedrdlock(
+ pthread_rwlock_t *rwlock,
+ const struct timespec *abstime
+)
+{
+ POSIX_RWLock_Control *the_rwlock;
+ Objects_Locations location;
+ Watchdog_Interval ticks;
+ int status;
+
+ if ( !rwlock )
+ return EINVAL;
+
+ status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
+ if ( !status )
+ return status;
+
+ the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
+ switch ( location ) {
+
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+
+ _CORE_RWLock_Obtain_for_reading(
+ &the_rwlock->RWLock,
+ *rwlock,
+ TRUE, // we are willing to wait up to ticks
+ ticks,
+ NULL
+ );
+
+ _Thread_Enable_dispatch();
+ return _POSIX_RWLock_Translate_core_RWLock_return_code(
+ (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
+ );
+ }
+
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/prwlocktimedwrlock.c b/cpukit/posix/src/prwlocktimedwrlock.c
new file mode 100644
index 0000000000..5a5253ad02
--- /dev/null
+++ b/cpukit/posix/src/prwlocktimedwrlock.c
@@ -0,0 +1,79 @@
+/*
+ * POSIX RWLock Manager -- Attempt to Obtain a Write Lock on a RWLock Instance
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/rwlock.h>
+#include <rtems/posix/time.h>
+
+/*
+ * pthread_rwlock_timedwrlock
+ *
+ * This directive attempts to obtain a write only lock on an rwlock instance.
+ *
+ * Input parameters:
+ * rwlock - pointer to rwlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_rwlock_timedwrlock(
+ pthread_rwlock_t *rwlock,
+ const struct timespec *abstime
+)
+{
+ POSIX_RWLock_Control *the_rwlock;
+ Objects_Locations location;
+ int status;
+ Watchdog_Interval ticks;
+
+ if ( !rwlock )
+ return EINVAL;
+
+ status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
+ if ( !status )
+ return status;
+
+ the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
+ switch ( location ) {
+
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+
+ _CORE_RWLock_Obtain_for_writing(
+ &the_rwlock->RWLock,
+ *rwlock,
+ TRUE, // we are willing to wait up to ticks
+ ticks,
+ NULL
+ );
+
+ _Thread_Enable_dispatch();
+ return _POSIX_RWLock_Translate_core_RWLock_return_code(
+ (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
+ );
+ }
+
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/prwlocktranslatereturncode.c b/cpukit/posix/src/prwlocktranslatereturncode.c
new file mode 100644
index 0000000000..5919643e4c
--- /dev/null
+++ b/cpukit/posix/src/prwlocktranslatereturncode.c
@@ -0,0 +1,51 @@
+/*
+ * RWLock Manager -- Translate SuperCore Status
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/rwlock.h>
+
+/*
+ * _POSIX_RWLock_Translate_core_rwlock_return_code
+ *
+ * Input parameters:
+ * the_rwlock_status - rwlock status code to translate
+ *
+ * Output parameters:
+ * status code - translated POSIX status code
+ *
+ */
+
+/* XXX fix me */
+static int _POSIX_RWLock_Return_codes[] = {
+ 0, /* CORE_RWLOCK_SUCCESSFUL */
+ EINVAL, /* CORE_RWLOCK_DELETED */
+ EBUSY, /* CORE_RWLOCK_UNAVAILABLE */
+ ETIMEDOUT, /* CORE_RWLOCK_TIMEOUT */
+};
+
+
+int _POSIX_RWLock_Translate_core_RWLock_return_code(
+ CORE_RWLock_Status the_rwlock_status
+)
+{
+ if ( the_rwlock_status <= CORE_RWLOCK_STATUS_LAST )
+ return _POSIX_RWLock_Return_codes[the_rwlock_status];
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/prwlocktryrdlock.c b/cpukit/posix/src/prwlocktryrdlock.c
new file mode 100644
index 0000000000..9d988dd7f2
--- /dev/null
+++ b/cpukit/posix/src/prwlocktryrdlock.c
@@ -0,0 +1,72 @@
+/*
+ * POSIX RWLock Manager -- Attempt to Obtain a Read Lock on a RWLock Instance
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/rwlock.h>
+
+/*
+ * pthread_rwlock_tryrdlock
+ *
+ * This directive attempts to obtain a read only lock on an rwlock instance.
+ *
+ * Input parameters:
+ * rwlock - pointer to rwlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_rwlock_tryrdlock(
+ pthread_rwlock_t *rwlock
+)
+{
+ POSIX_RWLock_Control *the_rwlock;
+ Objects_Locations location;
+
+ if ( !rwlock )
+ return EINVAL;
+
+ the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
+ switch ( location ) {
+
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+
+ _CORE_RWLock_Obtain_for_reading(
+ &the_rwlock->RWLock,
+ *rwlock,
+ FALSE, // do not wait for the rwlock
+ 0,
+ NULL
+ );
+
+
+ _Thread_Enable_dispatch();
+ return _POSIX_RWLock_Translate_core_RWLock_return_code(
+ (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
+ );
+ }
+
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/prwlocktrywrlock.c b/cpukit/posix/src/prwlocktrywrlock.c
new file mode 100644
index 0000000000..861a448447
--- /dev/null
+++ b/cpukit/posix/src/prwlocktrywrlock.c
@@ -0,0 +1,71 @@
+/*
+ * POSIX RWLock Manager -- Attempt to Obtain a Write Lock on a RWLock Instance
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/rwlock.h>
+
+/*
+ * pthread_rwlock_trywrlock
+ *
+ * This directive attempts to obtain a Write only lock on an rwlock instance.
+ *
+ * Input parameters:
+ * rwlock - pointer to rwlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_rwlock_trywrlock(
+ pthread_rwlock_t *rwlock
+)
+{
+ POSIX_RWLock_Control *the_rwlock;
+ Objects_Locations location;
+
+ if ( !rwlock )
+ return EINVAL;
+
+ the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
+ switch ( location ) {
+
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+
+ _CORE_RWLock_Obtain_for_writing(
+ &the_rwlock->RWLock,
+ *rwlock,
+ FALSE, // we are not willing to wait
+ 0,
+ NULL
+ );
+
+ _Thread_Enable_dispatch();
+ return _POSIX_RWLock_Translate_core_RWLock_return_code(
+ (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
+ );
+ }
+
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/prwlockunlock.c b/cpukit/posix/src/prwlockunlock.c
new file mode 100644
index 0000000000..99f971ab17
--- /dev/null
+++ b/cpukit/posix/src/prwlockunlock.c
@@ -0,0 +1,63 @@
+/*
+ * POSIX RWLock Manager -- Release a lock held on a RWLock Instance
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/rwlock.h>
+
+/*
+ * pthread_rwlock_unlock
+ *
+ * This directive attempts to release a lock on an RWLock.
+ *
+ * Input parameters:
+ * rwlock - pointer to rwlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_rwlock_unlock(
+ pthread_rwlock_t *rwlock
+)
+{
+ POSIX_RWLock_Control *the_rwlock;
+ Objects_Locations location;
+
+ if ( !rwlock )
+ return EINVAL;
+
+ the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
+ switch ( location ) {
+
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+
+ /* XXX */
+
+ _Thread_Enable_dispatch();
+ return 0;
+ }
+
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/prwlockwrlock.c b/cpukit/posix/src/prwlockwrlock.c
new file mode 100644
index 0000000000..dfacd90a30
--- /dev/null
+++ b/cpukit/posix/src/prwlockwrlock.c
@@ -0,0 +1,71 @@
+/*
+ * POSIX RWLock Manager -- Obtain a Write Lock on a RWLock Instance
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/rwlock.h>
+
+/*
+ * pthread_rwlock_wrlock
+ *
+ * This directive attempts to obtain a write only lock on an rwlock instance.
+ *
+ * Input parameters:
+ * rwlock - pointer to rwlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_rwlock_wrlock(
+ pthread_rwlock_t *rwlock
+)
+{
+ POSIX_RWLock_Control *the_rwlock;
+ Objects_Locations location;
+
+ if ( !rwlock )
+ return EINVAL;
+
+ the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
+ switch ( location ) {
+
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+
+ _CORE_RWLock_Obtain_for_writing(
+ &the_rwlock->RWLock,
+ *rwlock,
+ FALSE, /* do not timeout -- wait forever */
+ 0,
+ NULL
+ );
+
+ _Thread_Enable_dispatch();
+ return _POSIX_RWLock_Translate_core_RWLock_return_code(
+ (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
+ );
+ }
+
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/pspin.c b/cpukit/posix/src/pspin.c
new file mode 100644
index 0000000000..4a1379de27
--- /dev/null
+++ b/cpukit/posix/src/pspin.c
@@ -0,0 +1,60 @@
+/*
+ * Spinlock Manager
+ *
+ * DESCRIPTION:
+ *
+ * This package is the implementation of the Spinlock Manager.
+ *
+ * Directives provided are:
+ *
+ * + create a spinlock
+ * + get an ID of a spinlock
+ * + delete a spinlock
+ * + acquire a spinlock
+ * + release a spinlock
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/posix/spinlock.h>
+
+/**
+ * @brief _POSIX_Spinlock_Manager_initialization
+ *
+ * Input parameters:
+ * maximum_spinlocks - maximum configured spinlocks
+ *
+ * Output parameters: NONE
+ */
+
+void _POSIX_Spinlock_Manager_initialization(
+ uint32_t maximum_spinlocks
+)
+{
+ _Objects_Initialize_information(
+ &_POSIX_Spinlock_Information, /* object information table */
+ OBJECTS_POSIX_API, /* object API */
+ OBJECTS_POSIX_SPINLOCKS, /* object class */
+ maximum_spinlocks, /* maximum objects of this class */
+ sizeof( POSIX_Spinlock_Control ),/* size of this object's control block */
+ FALSE, /* TRUE if the name is a string */
+ 0 /* maximum length of an object name */
+#if defined(RTEMS_MULTIPROCESSING)
+ ,
+ FALSE, /* TRUE if this is a global object class */
+ NULL /* Proxy extraction support callout */
+#endif
+ );
+}
diff --git a/cpukit/posix/src/pspindestroy.c b/cpukit/posix/src/pspindestroy.c
new file mode 100644
index 0000000000..fb5d8cc738
--- /dev/null
+++ b/cpukit/posix/src/pspindestroy.c
@@ -0,0 +1,71 @@
+/*
+ * POSIX Spinlock Manager -- Destroy a Spinlock
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/spinlock.h>
+
+/*
+ * pthread_spin_destroy
+ *
+ * This directive allows a thread to delete a spinlock specified by
+ * the spinlock id. The spinlock is freed back to the inactive
+ * spinlock chain.
+ *
+ * Input parameters:
+ * spinlock - spinlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_spin_destroy(
+ pthread_spinlock_t *spinlock
+)
+{
+ POSIX_Spinlock_Control *the_spinlock = NULL;
+ Objects_Locations location;
+
+ if ( !spinlock )
+ return EINVAL;
+
+ the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
+ switch ( location ) {
+
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+ if ( _CORE_spinlock_Is_busy( &the_spinlock->Spinlock ) ) {
+ _Thread_Enable_dispatch();
+ return EBUSY;
+ }
+
+ _Objects_Close( &_POSIX_Spinlock_Information, &the_spinlock->Object );
+
+ _POSIX_Spinlock_Free( the_spinlock );
+
+ _Thread_Enable_dispatch();
+ return 0;
+ }
+
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/pspininit.c b/cpukit/posix/src/pspininit.c
new file mode 100644
index 0000000000..d7eb39a485
--- /dev/null
+++ b/cpukit/posix/src/pspininit.c
@@ -0,0 +1,80 @@
+/*
+ * POSIX Spinlock Manager -- Initialize a Spinlock Instance
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/spinlock.h>
+
+/*
+ * pthread_spinlock_init
+ *
+ * This directive creates a spinlock. A spinlock id is returned.
+ *
+ * Input parameters:
+ * spinlock - pointer to spinlock id
+ * pshared - is this spinlock shared between processes
+ *
+ * Output parameters:
+ * spinlock - spinlock id
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_spin_init(
+ pthread_spinlock_t *spinlock,
+ int pshared
+)
+{
+ POSIX_Spinlock_Control *the_spinlock;
+ CORE_spinlock_Attributes attributes;
+
+
+ if ( !spinlock )
+ return EINVAL;
+
+ switch ( pshared ) {
+ case PTHREAD_PROCESS_PRIVATE: /* only supported values */
+ break;
+ case PTHREAD_PROCESS_SHARED:
+ default:
+ return EINVAL;
+ }
+
+ _Thread_Disable_dispatch(); /* prevents deletion */
+
+ the_spinlock = _POSIX_Spinlock_Allocate();
+
+ if ( !the_spinlock ) {
+ _Thread_Enable_dispatch();
+ return EAGAIN;
+ }
+
+ _CORE_spinlock_Initialize( &the_spinlock->Spinlock, &attributes );
+
+ _Objects_Open(
+ &_POSIX_Spinlock_Information,
+ &the_spinlock->Object,
+ 0
+ );
+
+ *spinlock = the_spinlock->Object.id;
+
+ _Thread_Enable_dispatch();
+ return 0;
+}
diff --git a/cpukit/posix/src/pspinlock.c b/cpukit/posix/src/pspinlock.c
new file mode 100644
index 0000000000..9888b43c32
--- /dev/null
+++ b/cpukit/posix/src/pspinlock.c
@@ -0,0 +1,60 @@
+/*
+ * POSIX Spinlock Manager -- Wait at a Spinlock
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/spinlock.h>
+
+/*
+ * pthread_spin_lock
+ *
+ * This directive allows a thread to wait at a spinlock.
+ *
+ * Input parameters:
+ * spinlock - spinlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_spin_lock(
+ pthread_spinlock_t *spinlock
+)
+{
+ POSIX_Spinlock_Control *the_spinlock = NULL;
+ Objects_Locations location;
+ CORE_spinlock_Status status;
+
+ if ( !spinlock )
+ return EINVAL;
+
+ the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
+ switch ( location ) {
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+ status = _CORE_spinlock_Wait( &the_spinlock->Spinlock, TRUE, 0 );
+ _Thread_Enable_dispatch();
+ return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
+ }
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/pspinlocktranslatereturncode.c b/cpukit/posix/src/pspinlocktranslatereturncode.c
new file mode 100644
index 0000000000..0f72096c5a
--- /dev/null
+++ b/cpukit/posix/src/pspinlocktranslatereturncode.c
@@ -0,0 +1,53 @@
+/*
+ * Spinlock Manager -- Translate SuperCore Status
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/spinlock.h>
+
+/*
+ * _POSIX_Spinlock_Translate_core_spinlock_return_code
+ *
+ * Input parameters:
+ * the_spinlock_status - spinlock status code to translate
+ *
+ * Output parameters:
+ * status code - translated POSIX status code
+ *
+ */
+
+/* XXX fix me */
+static int _POSIX_Spinlock_Return_codes[] = {
+ 0, /* CORE_SPINLOCK_SUCCESSFUL */
+ EDEADLK, /* CORE_SPINLOCK_HOLDER_RELOCKING */
+ -1, /* CORE_SPINLOCK_TIMEOUT */
+ EBUSY, /* CORE_SPINLOCK_IS_BUSY */
+ EBUSY, /* CORE_SPINLOCK_UNAVAILABLE */
+ 0 /* CORE_SPINLOCK_NOT_LOCKED */
+};
+
+
+int _POSIX_Spinlock_Translate_core_spinlock_return_code(
+ CORE_spinlock_Status the_spinlock_status
+)
+{
+ if ( the_spinlock_status <= CORE_SPINLOCK_STATUS_LAST )
+ return _POSIX_Spinlock_Return_codes[the_spinlock_status];
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/pspintrylock.c b/cpukit/posix/src/pspintrylock.c
new file mode 100644
index 0000000000..a77b0e2b21
--- /dev/null
+++ b/cpukit/posix/src/pspintrylock.c
@@ -0,0 +1,60 @@
+/*
+ * POSIX Spinlock Manager -- Wait at a Spinlock
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/spinlock.h>
+
+/*
+ * pthread_spin_trylock
+ *
+ * This directive allows a thread to poll an attempt at locking a spinlock.
+ *
+ * Input parameters:
+ * spinlock - spinlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_spin_trylock(
+ pthread_spinlock_t *spinlock
+)
+{
+ POSIX_Spinlock_Control *the_spinlock = NULL;
+ Objects_Locations location;
+ CORE_spinlock_Status status;
+
+ if ( !spinlock )
+ return EINVAL;
+
+ the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
+ switch ( location ) {
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+ status = _CORE_spinlock_Wait( &the_spinlock->Spinlock, FALSE, 0 );
+ _Thread_Enable_dispatch();
+ return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
+ }
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/pspinunlock.c b/cpukit/posix/src/pspinunlock.c
new file mode 100644
index 0000000000..0af28ce56d
--- /dev/null
+++ b/cpukit/posix/src/pspinunlock.c
@@ -0,0 +1,60 @@
+/*
+ * POSIX Spinlock Manager -- Wait at a Spinlock
+ *
+ * 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$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/posix/spinlock.h>
+
+/*
+ * pthread_spin_unlock
+ *
+ * This directive allows a thread to wait at a spinlock.
+ *
+ * Input parameters:
+ * spinlock - spinlock id
+ *
+ * Output parameters:
+ * 0 - if successful
+ * error code - if unsuccessful
+ */
+
+int pthread_spin_unlock(
+ pthread_spinlock_t *spinlock
+)
+{
+ POSIX_Spinlock_Control *the_spinlock = NULL;
+ Objects_Locations location;
+ CORE_spinlock_Status status;
+
+ if ( !spinlock )
+ return EINVAL;
+
+ the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
+ switch ( location ) {
+ case OBJECTS_REMOTE:
+ case OBJECTS_ERROR:
+ return EINVAL;
+
+ case OBJECTS_LOCAL:
+ status = _CORE_spinlock_Release( &the_spinlock->Spinlock );
+ _Thread_Enable_dispatch();
+ return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
+ }
+ return POSIX_BOTTOM_REACHED();
+}
diff --git a/cpukit/posix/src/rwlockattrdestroy.c b/cpukit/posix/src/rwlockattrdestroy.c
new file mode 100644
index 0000000000..fc128ad610
--- /dev/null
+++ b/cpukit/posix/src/rwlockattrdestroy.c
@@ -0,0 +1,34 @@
+/*
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/score/object.h>
+#include <rtems/score/states.h>
+#include <rtems/score/watchdog.h>
+#include <rtems/posix/cond.h>
+#include <rtems/posix/time.h>
+#include <rtems/posix/mutex.h>
+
+/*PAGE
+ *
+ * RWLock Initialization Attributes
+ */
+
+int pthread_rwlockattr_destroy(
+ pthread_rwlockattr_t *attr
+)
+{
+ if ( !attr || attr->is_initialized == FALSE )
+ return EINVAL;
+
+ attr->is_initialized = FALSE;
+ return 0;
+}
diff --git a/cpukit/posix/src/rwlockattrgetpshared.c b/cpukit/posix/src/rwlockattrgetpshared.c
new file mode 100644
index 0000000000..3f829a759d
--- /dev/null
+++ b/cpukit/posix/src/rwlockattrgetpshared.c
@@ -0,0 +1,30 @@
+/*
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+/*PAGE
+ *
+ * RWLock Attributes Get Process Shared
+ */
+
+int pthread_rwlockattr_getpshared(
+ const pthread_rwlockattr_t *attr,
+ int *pshared
+)
+{
+ if ( !attr )
+ return EINVAL;
+
+ if ( !attr->is_initialized )
+ return EINVAL;
+
+ *pshared = attr->process_shared;
+ return 0;
+}
diff --git a/cpukit/posix/src/rwlockattrinit.c b/cpukit/posix/src/rwlockattrinit.c
new file mode 100644
index 0000000000..f0ab2c5f5b
--- /dev/null
+++ b/cpukit/posix/src/rwlockattrinit.c
@@ -0,0 +1,29 @@
+/*
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+
+/*PAGE
+ *
+ * RWLock Attributes Initialization
+ */
+
+int pthread_rwlockattr_init(
+ pthread_rwlockattr_t *attr
+)
+{
+ if ( !attr )
+ return EINVAL;
+
+ attr->is_initialized = TRUE;
+ attr->process_shared = PTHREAD_PROCESS_PRIVATE;
+ return 0;
+}
diff --git a/cpukit/posix/src/rwlockattrsetpshared.c b/cpukit/posix/src/rwlockattrsetpshared.c
new file mode 100644
index 0000000000..d122c5a0c1
--- /dev/null
+++ b/cpukit/posix/src/rwlockattrsetpshared.c
@@ -0,0 +1,37 @@
+/*
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+/*PAGE
+ *
+ * RWLock Attributes Set Process Shared
+ */
+
+int pthread_rwlockattr_setpshared(
+ pthread_rwlockattr_t *attr,
+ int pshared
+)
+{
+ if ( !attr )
+ return EINVAL;
+
+ if ( !attr->is_initialized )
+ return EINVAL;
+
+ switch ( pshared ) {
+ case PTHREAD_PROCESS_SHARED:
+ case PTHREAD_PROCESS_PRIVATE:
+ attr->process_shared = pshared;
+ return 0;
+
+ default:
+ return EINVAL;
+ }
+}