summaryrefslogtreecommitdiff
path: root/include/rtems/posix
diff options
context:
space:
mode:
authorAmar Takhar <amar@rtems.org>2015-12-11 17:42:52 -0500
committerAmar Takhar <amar@rtems.org>2015-12-11 17:42:52 -0500
commitea3940c92ee9aa6e3405ea2810a862ef78a44cd1 (patch)
tree781b4b1530ddcb8131b76bd87537c7e2721b568b /include/rtems/posix
parent4a85c73bd4bda4d314a91bb9ee4b3da5163e8221 (diff)
Stage 1: Move single headers.
Diffstat (limited to 'include/rtems/posix')
-rw-r--r--include/rtems/posix/aio_misc.h113
-rw-r--r--include/rtems/posix/barrier.h64
-rw-r--r--include/rtems/posix/barrierimpl.h115
-rw-r--r--include/rtems/posix/cancel.h50
-rw-r--r--include/rtems/posix/cond.h57
-rw-r--r--include/rtems/posix/condimpl.h128
-rw-r--r--include/rtems/posix/config.h156
-rw-r--r--include/rtems/posix/key.h91
-rw-r--r--include/rtems/posix/keyimpl.h205
-rw-r--r--include/rtems/posix/mqueue.h78
-rw-r--r--include/rtems/posix/mqueueimpl.h286
-rw-r--r--include/rtems/posix/mutex.h56
-rw-r--r--include/rtems/posix/muteximpl.h161
-rw-r--r--include/rtems/posix/posixapi.h84
-rw-r--r--include/rtems/posix/priorityimpl.h120
-rw-r--r--include/rtems/posix/psignal.h35
-rw-r--r--include/rtems/posix/psignalimpl.h152
-rw-r--r--include/rtems/posix/pthread.h55
-rw-r--r--include/rtems/posix/pthreadimpl.h238
-rw-r--r--include/rtems/posix/ptimer.h95
-rw-r--r--include/rtems/posix/rwlock.h63
-rw-r--r--include/rtems/posix/rwlockimpl.h106
-rw-r--r--include/rtems/posix/semaphore.h67
-rw-r--r--include/rtems/posix/semaphoreimpl.h191
-rw-r--r--include/rtems/posix/sigset.h45
-rw-r--r--include/rtems/posix/spinlock.h63
-rw-r--r--include/rtems/posix/spinlockimpl.h114
-rw-r--r--include/rtems/posix/threadsup.h121
-rw-r--r--include/rtems/posix/timer.h60
-rw-r--r--include/rtems/posix/timerimpl.h131
30 files changed, 3300 insertions, 0 deletions
diff --git a/include/rtems/posix/aio_misc.h b/include/rtems/posix/aio_misc.h
new file mode 100644
index 0000000000..aeccbad98f
--- /dev/null
+++ b/include/rtems/posix/aio_misc.h
@@ -0,0 +1,113 @@
+/**
+ * @file
+ *
+ * @brief POSIX Asynchronous Input and Output Private Support
+ *
+ * This defines private information for the AIO implementation.
+ */
+
+/*
+ * Copyright 2010, Alin Rus <alin.codejunkie@gmail.com>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _AIO_MISC_H
+#define _AIO_MISC_H
+
+#include <stdio.h>
+#include <string.h>
+#include <aio.h>
+#include <pthread.h>
+#include <rtems.h>
+#include <rtems/chain.h>
+#include <rtems/system.h>
+#include <rtems/seterr.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /* Actual request being processed */
+ typedef struct
+ {
+ rtems_chain_node next_prio; /* chain requests in order of priority */
+ int policy; /* If _POSIX_PRIORITIZED_IO and
+ _POSIX_PRIORITY_SCHEDULING are defined */
+ int priority; /* see above */
+ pthread_t caller_thread; /* used for notification */
+ struct aiocb *aiocbp; /* aio control block */
+ } rtems_aio_request;
+
+ typedef struct
+ {
+ rtems_chain_node next_fd; /* order fd chains in queue */
+ rtems_chain_control perfd; /* chain of requests for this fd */
+ int fildes; /* file descriptor to be processed */
+ int new_fd; /* if this is a newly created chain */
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+
+ } rtems_aio_request_chain;
+
+ typedef struct
+ {
+ pthread_mutex_t mutex;
+ pthread_cond_t new_req;
+ pthread_attr_t attr;
+
+ rtems_chain_control work_req; /* chains being worked by active threads */
+ rtems_chain_control idle_req; /* fd chains waiting to be processed */
+ unsigned int initialized; /* specific value if queue is initialized */
+ int active_threads; /* the number of active threads */
+ int idle_threads; /* number of idle threads */
+
+ } rtems_aio_queue;
+
+extern rtems_aio_queue aio_request_queue;
+
+#define AIO_QUEUE_INITIALIZED 0xB00B
+
+#ifndef AIO_MAX_THREADS
+#define AIO_MAX_THREADS 5
+#endif
+
+#ifndef AIO_MAX_QUEUE_SIZE
+#define AIO_MAX_QUEUE_SIZE 30
+#endif
+
+int rtems_aio_init (void);
+int rtems_aio_enqueue (rtems_aio_request *req);
+rtems_aio_request_chain *rtems_aio_search_fd
+(
+ rtems_chain_control *chain,
+ int fildes,
+ int create
+);
+void rtems_aio_remove_fd (rtems_aio_request_chain *r_chain);
+int rtems_aio_remove_req (rtems_chain_control *chain,
+ struct aiocb *aiocbp);
+
+#ifdef RTEMS_DEBUG
+#include <assert.h>
+
+#define AIO_assert(_x) assert(_x)
+#define AIO_printf(_x) printf(_x)
+#else
+#define AIO_assert(_x)
+#define AIO_printf(_x)
+#endif
+
+#define rtems_aio_set_errno_return_minus_one( _error, _aiocbp ) \
+ do { (_aiocbp)->error_code = (_error); \
+ (_aiocbp)->return_value = -1; \
+ rtems_set_errno_and_return_minus_one (_error);} while(0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/rtems/posix/barrier.h b/include/rtems/posix/barrier.h
new file mode 100644
index 0000000000..e445586511
--- /dev/null
+++ b/include/rtems/posix/barrier.h
@@ -0,0 +1,64 @@
+/**
+ * @file
+ *
+ * @brief Constants and Structures Associated with the POSIX Barrier Manager
+ *
+ * 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-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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_BARRIER_H
+#define _RTEMS_POSIX_BARRIER_H
+
+#include <rtems/score/object.h>
+#include <rtems/score/corebarrier.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup POSIXBarrier POSIX Barriers
+ *
+ * @ingroup POSIXAPI
+ *
+ * This encapsulates functionality which implements the RTEMS API
+ * Barrier Manager.
+ *
+ */
+/**@{**/
+
+/**
+ * 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;
+
+#ifdef __cplusplus
+}
+#endif
+
+/** @} */
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/barrierimpl.h b/include/rtems/posix/barrierimpl.h
new file mode 100644
index 0000000000..22be1c0d6e
--- /dev/null
+++ b/include/rtems/posix/barrierimpl.h
@@ -0,0 +1,115 @@
+/**
+ * @file
+ *
+ * @brief Inlined Routines from the POSIX Barrier Manager
+ *
+ * This file contains the static inlin implementation of the inlined
+ * routines from the POSIX Barrier Manager.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_BARRIERIMPL_H
+#define _RTEMS_POSIX_BARRIERIMPL_H
+
+#include <rtems/posix/barrier.h>
+#include <rtems/score/corebarrierimpl.h>
+#include <rtems/score/objectimpl.h>
+
+#include <pthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * 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.
+ */
+
+void _POSIX_Barrier_Manager_initialization(void);
+
+/**
+ * @brief POSIX translate 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
+);
+
+/**
+ * @brief Allocate a barrier control block.
+ *
+ * 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 Free a barrier control block.
+ *
+ * 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
+)
+{
+ _CORE_barrier_Destroy( &the_barrier->Barrier );
+ _Objects_Free( &_POSIX_Barrier_Information, &the_barrier->Object );
+}
+
+/**
+ * @brief Get a barrier control block.
+ *
+ * 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
+ );
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/cancel.h b/include/rtems/posix/cancel.h
new file mode 100644
index 0000000000..9e60c269ce
--- /dev/null
+++ b/include/rtems/posix/cancel.h
@@ -0,0 +1,50 @@
+/**
+ * @file
+ *
+ * @brief POSIX Thread Cancelation Support
+ *
+ * This file contains the prototypes and data types used to implement
+ * POSIX thread cancelation.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_CANCEL_H
+#define _RTEMS_POSIX_CANCEL_H
+
+#include <rtems/posix/threadsup.h>
+
+/**
+ * @brief POSIX run thread cancelation.
+ *
+ * This support routine runs through the chain of cancel handlers that
+ * have been registered and executes them.
+ *
+ * @param[in] the_thread is a pointer to the thread whose cancelation handlers
+ * should be run
+ */
+void _POSIX_Threads_cancel_run(
+ Thread_Control *the_thread
+);
+
+/**
+ * @brief POSIX evaluate thread cancelation and enable dispatch.
+ *
+ * This routine separates a piece of code that existed as part of
+ * another routine, but had to be separated to improve coverage.
+ *
+ * @param[in] the_thread is a pointer to the thread to evaluate canceling
+ */
+void _POSIX_Thread_Evaluate_cancellation_and_enable_dispatch (
+ Thread_Control *the_thread
+);
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/cond.h b/include/rtems/posix/cond.h
new file mode 100644
index 0000000000..00a0fdb9a4
--- /dev/null
+++ b/include/rtems/posix/cond.h
@@ -0,0 +1,57 @@
+/**
+ * @file
+ *
+ * @brief POSIX Condition Variables Private Support
+ *
+ * This include file contains all the private support information 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_COND_H
+#define _RTEMS_POSIX_COND_H
+
+#include <rtems/score/object.h>
+#include <rtems/score/threadq.h>
+
+#include <pthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup POSIX_COND_VARS POSIX Condition Variables
+ *
+ * @ingroup POSIXAPI
+ *
+ */
+/**@{**/
+
+/*
+ * Data Structure used to manage a POSIX condition variable
+ */
+
+typedef struct {
+ Objects_Control Object;
+ int process_shared;
+ pthread_mutex_t Mutex;
+ Thread_queue_Control Wait_queue;
+} POSIX_Condition_variables_Control;
+
+#ifdef __cplusplus
+}
+#endif
+
+/** @} */
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/condimpl.h b/include/rtems/posix/condimpl.h
new file mode 100644
index 0000000000..7def0f852a
--- /dev/null
+++ b/include/rtems/posix/condimpl.h
@@ -0,0 +1,128 @@
+/**
+ * @file
+ *
+ * This include file contains the static inline implementation of the private
+ * inlined routines for POSIX condition variables.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2013.
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_CONDIMPL_H
+#define _RTEMS_POSIX_CONDIMPL_H
+
+#include <rtems/posix/cond.h>
+#include <rtems/score/objectimpl.h>
+#include <rtems/score/threadqimpl.h>
+#include <rtems/score/watchdog.h>
+
+#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 POSIX Condition Variable Manager Initialization
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+void _POSIX_Condition_variables_Manager_initialization(void);
+
+/**
+ * @brief POSIX Condition Variable Allocate
+ *
+ * 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 )
+{
+ return (POSIX_Condition_variables_Control *)
+ _Objects_Allocate( &_POSIX_Condition_variables_Information );
+}
+
+/**
+ * @brief POSIX Condition Variable Free
+ *
+ * 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
+)
+{
+ _Thread_queue_Destroy( &the_condition_variable->Wait_queue );
+ _Objects_Free(
+ &_POSIX_Condition_variables_Information,
+ &the_condition_variable->Object
+ );
+}
+
+/**
+ * @brief POSIX Condition Variable Get
+ *
+ * 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.
+ */
+POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get (
+ pthread_cond_t *cond,
+ Objects_Locations *location
+);
+
+/**
+ * @brief Implements wake up version of the "signal" operation.
+ *
+ * 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.
+ *
+ * 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
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/config.h b/include/rtems/posix/config.h
new file mode 100644
index 0000000000..08d764b46a
--- /dev/null
+++ b/include/rtems/posix/config.h
@@ -0,0 +1,156 @@
+/**
+ * @file
+ *
+ * @brief User Defined Configuration Parameters Specific For The POSIX API
+ *
+ * This include file contains the table of user defined configuration
+ * parameters specific for the POSIX API.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2014.
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_CONFIG_H
+#define _RTEMS_POSIX_CONFIG_H
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup ClassicConfig Configuration
+ *
+ * @ingroup ClassicRTEMS
+ *
+ * This encapsulates functionality related to the application's configuration
+ * of the Classic API including the maximum number of each class of objects.
+ */
+/**@{*/
+
+/**
+ * For now, we are only allowing the user to specify the entry point
+ * and stack size for POSIX initialization threads.
+ */
+typedef struct {
+ /** This is the entry point for a POSIX initialization thread. */
+ void *(*thread_entry)(void *);
+ /** This is the stack size for a POSIX initialization thread. */
+ int stack_size;
+} posix_initialization_threads_table;
+
+/**
+ * The following records define the POSIX Configuration Table.
+ * The information contained in this table is required in all
+ * RTEMS systems which include POSIX threads support, whether
+ * single or multiprocessor. This table primarily defines the
+ * following:
+ *
+ * + required number of each object type
+ */
+typedef struct {
+ /**
+ * This field contains the maximum number of POSIX API
+ * threads which are configured for this application.
+ */
+ uint32_t maximum_threads;
+
+ /**
+ * This field contains the maximum number of POSIX API
+ * mutexes which are configured for this application.
+ */
+ uint32_t maximum_mutexes;
+
+ /**
+ * This field contains the maximum number of POSIX API
+ * condition variables which are configured for this application.
+ */
+ uint32_t maximum_condition_variables;
+
+ /**
+ * This field contains the maximum number of POSIX API
+ * timers which are configured for this application.
+ */
+ uint32_t maximum_timers;
+
+ /**
+ * This field contains the maximum number of POSIX API
+ * queued signals which are configured for this application.
+ */
+ uint32_t maximum_queued_signals;
+
+ /**
+ * This field contains the maximum number of POSIX API
+ * message queues which are configured for this application.
+ */
+ uint32_t maximum_message_queues;
+
+ /**
+ * This field contains the maximum number of POSIX API
+ * message queue file descriptors which are configured
+ * for this application.
+ *
+ * @note There can be one or more file descriptors used with
+ * each message queue. This value should be greater than
+ * or equal to the number of message queues.
+ */
+ uint32_t maximum_message_queue_descriptors;
+
+ /**
+ * This field contains the maximum number of POSIX API
+ * semaphores which are configured for this application.
+ */
+ uint32_t maximum_semaphores;
+
+ /**
+ * This field contains the maximum number of POSIX API
+ * barriers which are configured for this application.
+ */
+ uint32_t maximum_barriers;
+
+ /**
+ * This field contains the maximum number of POSIX API
+ * read/write locks which are configured for this application.
+ */
+ uint32_t maximum_rwlocks;
+
+ /**
+ * This field contains the maximum number of POSIX API
+ * spinlocks which are configured for this application.
+ */
+ uint32_t maximum_spinlocks;
+
+ /**
+ * This field contains the number of POSIX API Initialization
+ * threads listed in @a User_initialization_thread_table.
+ */
+ uint32_t number_of_initialization_threads;
+
+ /**
+ * This field contains the list of POSIX API Initialization threads.
+ */
+ posix_initialization_threads_table *User_initialization_threads_table;
+} posix_api_configuration_table;
+
+/**
+ * @brief POSIX API configuration table.
+ *
+ * This is the POSIX API Configuration Table expected to be generated
+ * by confdefs.h.
+ */
+extern posix_api_configuration_table Configuration_POSIX_API;
+
+/**@}*/
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/key.h b/include/rtems/posix/key.h
new file mode 100644
index 0000000000..6e52544686
--- /dev/null
+++ b/include/rtems/posix/key.h
@@ -0,0 +1,91 @@
+/**
+ * @file
+ *
+ * @brief POSIX Key Private Support
+ *
+ * This include file contains all the private support information for
+ * POSIX key.
+ */
+
+/*
+ * Copyright (c) 2012 Zhongwei Yao.
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_KEY_H
+#define _RTEMS_POSIX_KEY_H
+
+#include <pthread.h>
+
+#include <rtems/score/chain.h>
+#include <rtems/score/object.h>
+#include <rtems/score/rbtree.h>
+#include <rtems/score/thread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup POSIX_KEY POSIX Key
+ *
+ * @ingroup POSIXAPI
+ *
+ */
+/**@{**/
+
+/**
+ * @brief Represents POSIX key and value pair.
+ */
+typedef struct {
+ /**
+ * @brief The chain node for the per-thread value chain.
+ */
+ Chain_Node Key_values_per_thread_node;
+
+ /**
+ * @brief The tree node for the lookup tree.
+ */
+ RBTree_Node Key_value_lookup_node;
+
+ /**
+ * @brief The POSIX key identifier used in combination with the thread
+ * pointer as the tree key.
+ */
+ pthread_key_t key;
+
+ /**
+ * @brief The thread pointer used in combination with the POSIX key
+ * identifier as the tree key.
+ */
+ Thread_Control *thread;
+
+ /**
+ * @brief The thread specific POSIX key value.
+ */
+ void *value;
+} POSIX_Keys_Key_value_pair;
+
+/**
+ * @brief The data structure used to manage a POSIX key.
+ */
+typedef struct {
+ /** This field is the Object control structure. */
+ Objects_Control Object;
+ /** This field is the data destructor. */
+ void (*destructor) (void *);
+ } POSIX_Keys_Control;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/keyimpl.h b/include/rtems/posix/keyimpl.h
new file mode 100644
index 0000000000..6fd4d1348a
--- /dev/null
+++ b/include/rtems/posix/keyimpl.h
@@ -0,0 +1,205 @@
+/**
+ * @file
+ *
+ * @brief Private Inlined Routines for POSIX Key's
+ *
+ * This include file contains the static inline implementation of the private
+ * inlined routines for POSIX key's.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-1999.
+ * 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.org/license/LICENSE.
+ */
+
+#include <rtems/posix/key.h>
+#include <rtems/score/chainimpl.h>
+#include <rtems/score/freechain.h>
+#include <rtems/score/objectimpl.h>
+#include <rtems/score/percpu.h>
+
+#ifndef _RTEMS_POSIX_KEYIMPL_H
+#define _RTEMS_POSIX_KEYIMPL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup POSIX_KEY
+ *
+ * @{
+ */
+
+/**
+ * @brief The information control block used to manage this class of objects.
+ */
+POSIX_EXTERN Objects_Information _POSIX_Keys_Information;
+
+/**
+ * @brief The rbtree control block used to manage all key values
+ */
+extern RBTree_Control _POSIX_Keys_Key_value_lookup_tree;
+
+/**
+ * @brief This freechain is used as a memory pool for POSIX_Keys_Key_value_pair.
+ */
+POSIX_EXTERN Freechain_Control _POSIX_Keys_Keypool;
+
+#define POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node ) \
+ RTEMS_CONTAINER_OF( node, POSIX_Keys_Key_value_pair, Key_value_lookup_node )
+
+/**
+ * @brief POSIX key manager initialization.
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+void _POSIX_Key_Manager_initialization(void);
+
+/**
+ * @brief POSIX keys Red-Black tree node comparison.
+ *
+ * This routine compares the rbtree node
+ */
+RBTree_Compare_result _POSIX_Keys_Key_value_compare(
+ const RBTree_Node *node1,
+ const RBTree_Node *node2
+);
+
+/**
+ * @brief Create thread-specific data POSIX key.
+ *
+ * This function executes all the destructors associated with the thread's
+ * keys. This function will execute until all values have been set to NULL.
+ *
+ * @param[in] thread is a pointer to the thread whose keys should have
+ * all their destructors run.
+ *
+ * NOTE: This is the routine executed when a thread exits to
+ * run through all the keys and do the destructor action.
+ */
+void _POSIX_Keys_Run_destructors(
+ Thread_Control *thread
+);
+
+/**
+ * @brief Free a POSIX key table memory.
+ *
+ * This memory frees the key table memory associated with @a the_key.
+ *
+ * @param[in] the_key is a pointer to the POSIX key to free
+ * the table memory of.
+ */
+void _POSIX_Keys_Free_memory(
+ POSIX_Keys_Control *the_key
+);
+
+/**
+ * @brief Free a POSIX keys control block.
+ *
+ * This routine frees a keys control block to the
+ * inactive chain of free keys control blocks.
+ *
+ * @param[in] the_key is a pointer to the POSIX key to free.
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free (
+ POSIX_Keys_Control *the_key
+);
+
+/**
+ * @brief Allocate a keys control block.
+ *
+ * This function allocates a keys control block from
+ * the inactive chain of free keys control blocks.
+ */
+
+RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Allocate( void )
+{
+ return (POSIX_Keys_Control *) _Objects_Allocate( &_POSIX_Keys_Information );
+}
+
+/**
+ * @brief Free a keys control block.
+ *
+ * This routine frees a keys control block to the
+ * inactive chain of free keys control blocks.
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free (
+ POSIX_Keys_Control *the_key
+)
+{
+ _Objects_Free( &_POSIX_Keys_Information, &the_key->Object );
+}
+
+/**
+ * @brief Get a keys control block.
+ *
+ * This function maps key IDs to key control blocks.
+ * If ID corresponds to a local keys, then it returns
+ * the_key control pointer which maps to ID and location
+ * is set to OBJECTS_LOCAL. if the keys ID is global and
+ * resides on a remote node, then location is set to OBJECTS_REMOTE,
+ * and the_key is undefined. Otherwise, location is set
+ * to OBJECTS_ERROR and the_key is undefined.
+ */
+
+RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Get (
+ pthread_key_t id,
+ Objects_Locations *location
+)
+{
+ return (POSIX_Keys_Control *)
+ _Objects_Get( &_POSIX_Keys_Information, (Objects_Id) id, location );
+}
+
+POSIX_Keys_Key_value_pair * _POSIX_Keys_Key_value_pair_allocate( void );
+
+RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_pair_free(
+ POSIX_Keys_Key_value_pair *key_value_pair
+)
+{
+ _Freechain_Put( &_POSIX_Keys_Keypool, key_value_pair );
+}
+
+RTEMS_INLINE_ROUTINE RBTree_Node *_POSIX_Keys_Find(
+ pthread_key_t key,
+ Thread_Control *thread
+)
+{
+ POSIX_Keys_Key_value_pair search_node;
+
+ search_node.key = key;
+ search_node.thread = thread;
+
+ return _RBTree_Find(
+ &_POSIX_Keys_Key_value_lookup_tree,
+ &search_node.Key_value_lookup_node,
+ _POSIX_Keys_Key_value_compare,
+ true
+ );
+}
+
+RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free_key_value_pair(
+ POSIX_Keys_Key_value_pair *key_value_pair
+)
+{
+ _RBTree_Extract(
+ &_POSIX_Keys_Key_value_lookup_tree,
+ &key_value_pair->Key_value_lookup_node
+ );
+ _Chain_Extract_unprotected( &key_value_pair->Key_values_per_thread_node );
+ _POSIX_Keys_Key_value_pair_free( key_value_pair );
+}
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/mqueue.h b/include/rtems/posix/mqueue.h
new file mode 100644
index 0000000000..473183d4bc
--- /dev/null
+++ b/include/rtems/posix/mqueue.h
@@ -0,0 +1,78 @@
+/**
+ * @file
+ *
+ * @brief POSIX Message Queues Private Private Support
+ *
+ * This include file contains all the private support information for
+ * POSIX Message Queues.
+ *
+ * The structure of the routines is identical to that of POSIX
+ * Message_queues to leave the option of having unnamed message
+ * queues at a future date. They are currently not part of the
+ * POSIX standard but unnamed message_queues are. This is also
+ * the reason for the apparently unnecessary tracking of
+ * the process_shared attribute. [In addition to the fact that
+ * it would be trivial to add pshared to the mq_attr structure
+ * and have process private message queues.]
+ *
+ * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
+ * time.
+ */
+
+/*
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_MQUEUE_H
+#define _RTEMS_POSIX_MQUEUE_H
+
+#include <signal.h>
+#include <mqueue.h> /* struct mq_attr */
+#include <rtems/score/coremsg.h>
+#include <rtems/score/object.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup POSIX_MQUEUE_P Message Queues Private Support
+ *
+ * @ingroup POSIXAPI
+ *
+ */
+/**@{**/
+
+/*
+ * Data Structure used to manage a POSIX message queue
+ */
+
+typedef struct {
+ Objects_Control Object;
+ int process_shared;
+ bool named;
+ bool linked;
+ uint32_t open_count;
+ CORE_message_queue_Control Message_queue;
+ struct sigevent notification;
+} POSIX_Message_queue_Control;
+
+typedef struct {
+ Objects_Control Object;
+ POSIX_Message_queue_Control *Queue;
+ int oflag;
+} POSIX_Message_queue_Control_fd;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/mqueueimpl.h b/include/rtems/posix/mqueueimpl.h
new file mode 100644
index 0000000000..90269bf57b
--- /dev/null
+++ b/include/rtems/posix/mqueueimpl.h
@@ -0,0 +1,286 @@
+/**
+ * @file
+ *
+ * @brief Private Inlined Routines for POSIX Message Queue
+ *
+ * This include file contains the static inline implementation of the private
+ * inlined routines for POSIX Message Queue.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2013.
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_MQUEUE_INL
+#define _RTEMS_POSIX_MQUEUE_INL
+
+#include <rtems/posix/mqueue.h>
+#include <rtems/posix/posixapi.h>
+#include <rtems/score/coremsgimpl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * This defines the information control block used to manage
+ * this class of objects.
+ */
+POSIX_EXTERN Objects_Information _POSIX_Message_queue_Information;
+
+/**
+ * The is used to manage the set of "file descriptors" associated with
+ * the message queues.
+ */
+POSIX_EXTERN Objects_Information _POSIX_Message_queue_Information_fds;
+
+/**
+ * @brief Initialize message_queue manager related data structures.
+ *
+ * This routine performs the initialization necessary for this manager.
+ *
+ * @note The structure of the routines is identical to that of POSIX
+ * Message_queues to leave the option of having unnamed message
+ * queues at a future date. They are currently not part of the
+ * POSIX standard but unnamed message_queues are. This is also
+ * the reason for the apparently unnecessary tracking of
+ * the process_shared attribute. [In addition to the fact that
+ * it would be trivial to add pshared to the mq_attr structure
+ * and have process private message queues.]
+ *
+ * @note This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open time.
+ *
+ */
+void _POSIX_Message_queue_Manager_initialization(void);
+
+/**
+ * @brief POSIX Message Queue Create Support
+ *
+ * This routine performs the creation of a message queue utilizing the
+ * core message queue.
+ */
+int _POSIX_Message_queue_Create_support(
+ const char *name,
+ size_t name_len,
+ int pshared,
+ struct mq_attr *attr,
+ POSIX_Message_queue_Control **message_queue
+);
+
+/**
+ * @brief Delete a POSIX Message Queue
+ *
+ * This routine supports the mq_unlink and mq_close routines by
+ * doing most of the work involved with removing a message queue.
+ */
+void _POSIX_Message_queue_Delete(
+ POSIX_Message_queue_Control *the_mq
+);
+
+/*@
+ * @brief POSIX Message Queue Receive Support
+ *
+ * This routine supports the various flavors of receiving a message.
+ *
+ * @note The structure of the routines is identical to that of POSIX
+ * Message_queues to leave the option of having unnamed message
+ * queues at a future date. They are currently not part of the
+ * POSIX standard but unnamed message_queues are. This is also
+ * the reason for the apparently unnecessary tracking of
+ * the process_shared attribute. [In addition to the fact that
+ * it would be trivial to add pshared to the mq_attr structure
+ * and have process private message queues.]
+ *
+ * @note This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open time.
+ */
+ssize_t _POSIX_Message_queue_Receive_support(
+ mqd_t mqdes,
+ char *msg_ptr,
+ size_t msg_len,
+ unsigned int *msg_prio,
+ bool wait,
+ Watchdog_Interval timeout
+);
+
+/**
+ * @brief POSIX Message Queue Send Support
+ *
+ * This routine posts a message to a specified message queue.
+ */
+int _POSIX_Message_queue_Send_support(
+ mqd_t mqdes,
+ const char *msg_ptr,
+ size_t msg_len,
+ unsigned int msg_prio,
+ bool wait,
+ Watchdog_Interval timeout
+);
+
+/**
+ * @brief POSIX Message Queue Allocate
+ *
+ * This function allocates a message queue control block from
+ * the inactive chain of free message queue control blocks.
+ */
+RTEMS_INLINE_ROUTINE
+ POSIX_Message_queue_Control *_POSIX_Message_queue_Allocate( void )
+{
+ return (POSIX_Message_queue_Control *)
+ _Objects_Allocate( &_POSIX_Message_queue_Information );
+}
+
+/**
+ * @brief POSIX Message Queue Free
+ *
+ * This routine frees a message queue control block to the
+ * inactive chain of free message queue control blocks.
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free(
+ POSIX_Message_queue_Control *the_mq
+)
+{
+ _Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object );
+}
+
+
+/**
+ * @brief POSIX Message Queue Get
+ *
+ * This function maps message queue IDs to message queue control blocks.
+ * If ID corresponds to a local message queue, then it returns
+ * the_mq control pointer which maps to ID and location
+ * is set to OBJECTS_LOCAL. if the message queue ID is global and
+ * resides on a remote node, then location is set to OBJECTS_REMOTE,
+ * and the_message queue is undefined. Otherwise, location is set
+ * to OBJECTS_ERROR and the_mq is undefined.
+ */
+RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get (
+ Objects_Id id,
+ Objects_Locations *location
+)
+{
+ return (POSIX_Message_queue_Control *)
+ _Objects_Get( &_POSIX_Message_queue_Information, id, location );
+}
+
+/*
+ * @brief POSIX Message Queue Convert Message Priority to Score
+ *
+ * This method converts a POSIX message priority to the priorities used
+ * by the Score.
+ */
+RTEMS_INLINE_ROUTINE CORE_message_queue_Submit_types
+ _POSIX_Message_queue_Priority_to_core(
+ unsigned int priority
+)
+{
+ return (CORE_message_queue_Submit_types) priority * -1;
+}
+
+
+/*
+ * @brief POSIX Message Queue Convert Message Priority from Score
+ *
+ * This method converts a POSIX message priority from the priorities used
+ * by the Score.
+ */
+RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core(
+ CORE_message_queue_Submit_types priority
+)
+{
+ /* absolute value without a library dependency */
+ return (unsigned int) ((priority >= 0) ? priority : -priority);
+}
+
+/**
+ * @brief POSIX Message Queue Translate Score Return Code
+ *
+ */
+int _POSIX_Message_queue_Translate_core_message_queue_return_code(
+ uint32_t the_message_queue_status
+);
+
+/**
+ * @brief POSIX Message Queue Allocate File Descriptor
+ */
+RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd *
+ _POSIX_Message_queue_Allocate_fd( void )
+{
+ return (POSIX_Message_queue_Control_fd *)
+ _Objects_Allocate( &_POSIX_Message_queue_Information_fds );
+}
+
+/**
+ * @brief POSIX Message Queue Free File Descriptor
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free_fd (
+ POSIX_Message_queue_Control_fd *the_mq_fd
+)
+{
+ _Objects_Free( &_POSIX_Message_queue_Information_fds, &the_mq_fd->Object );
+}
+
+/**
+ * @brief POSIX Message Queue Remove from Namespace
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Namespace_remove (
+ POSIX_Message_queue_Control *the_mq
+)
+{
+ _Objects_Namespace_remove(
+ &_POSIX_Message_queue_Information, &the_mq->Object );
+}
+
+/*
+ * @brief POSIX Message Queue Get File Descriptor
+ */
+RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd *_POSIX_Message_queue_Get_fd (
+ mqd_t id,
+ Objects_Locations *location
+)
+{
+ return (POSIX_Message_queue_Control_fd *) _Objects_Get(
+ &_POSIX_Message_queue_Information_fds,
+ (Objects_Id)id,
+ location
+ );
+}
+
+RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd *
+_POSIX_Message_queue_Get_fd_interrupt_disable(
+ mqd_t id,
+ Objects_Locations *location,
+ ISR_lock_Context *lock_context
+)
+{
+ return (POSIX_Message_queue_Control_fd *) _Objects_Get_isr_disable(
+ &_POSIX_Message_queue_Information_fds,
+ (Objects_Id)id,
+ location,
+ lock_context
+ );
+}
+
+/**
+ * @see _POSIX_Name_to_id().
+ */
+RTEMS_INLINE_ROUTINE int _POSIX_Message_queue_Name_to_id(
+ const char *name,
+ Objects_Id *id,
+ size_t *len
+)
+{
+ return _POSIX_Name_to_id( &_POSIX_Message_queue_Information, name, id, len );
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/mutex.h b/include/rtems/posix/mutex.h
new file mode 100644
index 0000000000..5243d4cbbb
--- /dev/null
+++ b/include/rtems/posix/mutex.h
@@ -0,0 +1,56 @@
+/**
+ * @file
+ *
+ * @brief POSIX MUTEX Support
+ *
+ * This include file contains all the private support information for
+ * POSIX mutex's.
+ */
+
+/*
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_MUTEX_H
+#define _RTEMS_POSIX_MUTEX_H
+
+#include <rtems/score/coremutex.h>
+#include <pthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup POSIX_MUTEX POSIX Mutex Support
+ *
+ * @ingroup POSIXAPI
+ *
+ * @brief Private Support Information for POSIX Mutex
+ *
+ */
+/**@{**/
+
+/*
+ * Data Structure used to manage a POSIX mutex
+ */
+
+typedef struct {
+ Objects_Control Object;
+ int process_shared;
+ CORE_mutex_Control Mutex;
+} POSIX_Mutex_Control;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/muteximpl.h b/include/rtems/posix/muteximpl.h
new file mode 100644
index 0000000000..f4c6c686aa
--- /dev/null
+++ b/include/rtems/posix/muteximpl.h
@@ -0,0 +1,161 @@
+/**
+ * @file
+ *
+ * @brief Private Inlined Routines for POSIX Mutex's.
+ *
+ * This include file contains the static inline implementation of the private
+ * inlined routines for POSIX mutex's.
+ */
+
+/* COPYRIGHT (c) 1989-2013.
+ * 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.org/license/LICENSE.
+ */
+
+#include <rtems/posix/mutex.h>
+#include <rtems/score/coremuteximpl.h>
+
+#include <errno.h>
+
+#ifndef _RTEMS_POSIX_MUTEXIMPL_H
+#define _RTEMS_POSIX_MUTEXIMPL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * The following defines the information control block used to manage
+ * this class of objects.
+ */
+POSIX_EXTERN Objects_Information _POSIX_Mutex_Information;
+
+/**
+ * The default mutex attributes structure.
+ */
+POSIX_EXTERN pthread_mutexattr_t _POSIX_Mutex_Default_attributes;
+
+/**
+ * This array contains a mapping from Score Mutex return codes to
+ * POSIX return codes.
+ */
+extern const int _POSIX_Mutex_Return_codes[CORE_MUTEX_STATUS_LAST + 1];
+
+/**
+ * @brief POSIX Mutex Manager Initialization
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+void _POSIX_Mutex_Manager_initialization(void);
+
+/**
+ * @brief POSIX Mutex Allocate
+ *
+ * This function allocates a mutexes control block from
+ * the inactive chain of free mutexes control blocks.
+ */
+RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Allocate( void )
+{
+ return (POSIX_Mutex_Control *) _Objects_Allocate( &_POSIX_Mutex_Information );
+}
+
+/**
+ * @brief POSIX Mutex Free
+ *
+ * This routine frees a mutexes control block to the
+ * inactive chain of free mutexes control blocks.
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Free(
+ POSIX_Mutex_Control *the_mutex
+)
+{
+ _CORE_mutex_Destroy( &the_mutex->Mutex );
+ _Objects_Free( &_POSIX_Mutex_Information, &the_mutex->Object );
+}
+
+
+/**
+ * @brief POSIX Mutex Lock Support Method
+ *
+ * A support routine which implements guts of the blocking, non-blocking, and
+ * timed wait version of mutex lock.
+ */
+int _POSIX_Mutex_Lock_support(
+ pthread_mutex_t *mutex,
+ bool blocking,
+ Watchdog_Interval timeout
+);
+
+/**
+ * @brief Convert Score mutex status codes into POSIX status values
+ *
+ * A support routine which converts core mutex status codes into the
+ * appropriate POSIX status values.
+ *
+ * @param[in] the_mutex_status is the mutex status code to translate
+ *
+ * @retval 0 Mutex status code indicates the operation completed successfully.
+ * @retval EBUSY Mutex status code indicates that the operation unable to
+ * complete immediately because the resource was unavailable.
+ * @retval EDEADLK Mutex status code indicates that an attempt was made to
+ * relock a mutex for which nesting is not configured.
+ * @retval EPERM Mutex status code indicates that an attempt was made to
+ * release a mutex by a thread other than the thread which locked it.
+ * @retval EINVAL Mutex status code indicates that the thread was blocked
+ * waiting for an operation to complete and the mutex was deleted.
+ * @retval ETIMEDOUT Mutex status code indicates that the calling task was
+ * willing to block but the operation was unable to complete
+ * within the time allotted because the resource never became
+ * available.
+ */
+RTEMS_INLINE_ROUTINE int _POSIX_Mutex_Translate_core_mutex_return_code(
+ CORE_mutex_Status the_mutex_status
+)
+{
+ /*
+ * Internal consistency check for bad status from SuperCore
+ */
+ #if defined(RTEMS_DEBUG)
+ if ( the_mutex_status > CORE_MUTEX_STATUS_LAST )
+ return EINVAL;
+ #endif
+ return _POSIX_Mutex_Return_codes[the_mutex_status];
+}
+
+/**
+ * @brief POSIX Mutex Get (Thread Dispatch Disable)
+ *
+ * A support routine which translates the mutex id into a local pointer.
+ * As a side-effect, it may create the mutex.
+ *
+ * @note This version of the method uses a dispatching critical section.
+ */
+POSIX_Mutex_Control *_POSIX_Mutex_Get (
+ pthread_mutex_t *mutex,
+ Objects_Locations *location
+);
+
+/**
+ * @brief POSIX Mutex Get (Interrupt Disable)
+ *
+ * A support routine which translates the mutex id into a local pointer.
+ * As a side-effect, it may create the mutex.
+ *
+ * @note: This version of the method uses an interrupt critical section.
+ */
+POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
+ pthread_mutex_t *mutex,
+ Objects_Locations *location,
+ ISR_lock_Context *lock_context
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
+
diff --git a/include/rtems/posix/posixapi.h b/include/rtems/posix/posixapi.h
new file mode 100644
index 0000000000..ec8b8453ff
--- /dev/null
+++ b/include/rtems/posix/posixapi.h
@@ -0,0 +1,84 @@
+/**
+ * @file
+ *
+ * @brief POSIX API Implementation
+ *
+ * This include file defines the top level interface to the POSIX API
+ * implementation in RTEMS.
+ */
+
+/*
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_POSIXAPI_H
+#define _RTEMS_POSIX_POSIXAPI_H
+
+#include <rtems/config.h>
+#include <rtems/score/objectimpl.h>
+
+/**
+ * @defgroup POSIXAPI RTEMS POSIX API
+ *
+ * RTEMS POSIX API definitions and modules.
+ *
+ */
+/**@{**/
+
+/**
+ * @brief POSIX API Fatal domains.
+ */
+typedef enum {
+ POSIX_FD_PTHREAD, /**< A pthread thread error. */
+ POSIX_FD_PTHREAD_ONCE /**< A pthread once error. */
+} POSIX_Fatal_domain;
+
+/**
+ * @brief POSIX API Fatal error.
+ *
+ * A common method of rasing a POSIX API fatal error.
+ *
+ * @param[in] domain The POSIX error domain.
+ * @param[in] eno The error number as defined in errno.h.
+ */
+void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno );
+
+/**
+ * @brief Initialize POSIX API.
+ *
+ * This method is responsible for initializing each of the POSIX
+ * API managers.
+ */
+void _POSIX_API_Initialize(void);
+
+/**
+ * @brief Queries the object identifier @a id for a @a name.
+ *
+ * @param[in] information Object information.
+ * @param[in] name Zero terminated name string to look up.
+ * @param[out] id Pointer for identifier. The pointer must be valid.
+ * @param[out] len Pointer for string length. The pointer must be valid.
+ *
+ * @retval 0 Successful operation.
+ * @retval EINVAL The @a name pointer is @c NULL or the @a name string has
+ * zero length.
+ * @retval ENAMETOOLONG The @a name string length is greater than or equal to
+ * @c NAME_MAX.
+ * @retval ENOENT Found no corresponding identifier.
+ */
+int _POSIX_Name_to_id(
+ Objects_Information *information,
+ const char *name,
+ Objects_Id *id,
+ size_t *len
+);
+
+/** @} */
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/priorityimpl.h b/include/rtems/posix/priorityimpl.h
new file mode 100644
index 0000000000..169254d22f
--- /dev/null
+++ b/include/rtems/posix/priorityimpl.h
@@ -0,0 +1,120 @@
+/**
+ * @file
+ *
+ * @brief POSIX Priority Support
+ *
+ * This include file defines the interface to the POSIX priority
+ * implementation.
+ */
+
+/*
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_PRIORITYIMPL_H
+#define _RTEMS_POSIX_PRIORITYIMPL_H
+
+#include <rtems/score/priority.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup POSIX_PRIORITY POSIX Priority Support
+ *
+ * @ingroup POSIXAPI
+ *
+ * @brief Interface to the POSIX Priority Implementation
+ *
+ */
+/**@{**/
+
+/**
+ * 1003.1b-1993,2.2.2.80 definition of priority, p. 19
+ *
+ * "Numerically higher values represent higher priorities."
+ *
+ * Thus, RTEMS Core has priorities run in the opposite sense of the POSIX API.
+ *
+ * There are only 254 posix priority levels since a task at priority level
+ * 255 would never run because of the RTEMS idle task. This is necessary
+ * because GNAT maps the lowest Ada task priority to the lowest thread
+ * priority. The lowest priority Ada task should get to run, so there is
+ * a fundamental conflict with having 255 priorities.
+ *
+ * But since RTEMS can be configured with fewer than 256 priorities,
+ * we use the internal constant.
+ */
+#define POSIX_SCHEDULER_MAXIMUM_PRIORITY (PRIORITY_MAXIMUM - 1)
+
+
+/**
+ * This is the numerically least important POSIX priority.
+ */
+#define POSIX_SCHEDULER_MINIMUM_PRIORITY (1)
+
+/**
+ * @brief Check if POSIX priority is valid.
+ *
+ * 1003.1b-1993,2.2.2.80 definition of priority, p. 19
+ *
+ * "Numerically higher values represent higher priorities."
+ *
+ * Thus, RTEMS Core has priorities run in the opposite sense of the POSIX API.
+ *
+ * @param[in] priority is the priority to test
+ *
+ * @retval TRUE The priority is valid.
+ * @retval FALSE The priority is invalid.
+ */
+bool _POSIX_Priority_Is_valid(
+ int priority
+);
+
+/**
+ * @brief Convert POSIX priority to SuperCore priority.
+ *
+ * This method converts a POSIX API priority into onto the corresponding
+ * SuperCore value.
+ *
+ * @param[in] priority is the POSIX API priority.
+ *
+ * @return This method returns the corresponding SuperCore priority.
+ */
+RTEMS_INLINE_ROUTINE Priority_Control _POSIX_Priority_To_core(
+ int priority
+)
+{
+ return (Priority_Control) (POSIX_SCHEDULER_MAXIMUM_PRIORITY - priority + 1);
+}
+
+/**
+ * @brief Convert SuperCore priority To POSIX priority.
+ *
+ * This method converts a SuperCore priority into onto the corresponding
+ * POSIX API value.
+ *
+ * @param[in] priority is the POSIX API priority.
+ *
+ * @return This method returns the corresponding POSIX priority.
+ */
+RTEMS_INLINE_ROUTINE int _POSIX_Priority_From_core(
+ Priority_Control priority
+)
+{
+ return (POSIX_SCHEDULER_MAXIMUM_PRIORITY - priority + 1);
+}
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/rtems/posix/psignal.h b/include/rtems/posix/psignal.h
new file mode 100644
index 0000000000..ed98442e32
--- /dev/null
+++ b/include/rtems/posix/psignal.h
@@ -0,0 +1,35 @@
+/**
+ * @file
+ *
+ * @brief Internal Information about POSIX Signals
+ *
+ * This include file defines internal information about POSIX signals.
+ */
+
+/*
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_PSIGNAL_H
+#define _RTEMS_POSIX_PSIGNAL_H
+
+#include <sys/signal.h>
+
+#include <rtems/score/chain.h>
+
+/*
+ * POSIX internal siginfo structure
+ */
+
+typedef struct {
+ Chain_Node Node;
+ siginfo_t Info;
+} POSIX_signals_Siginfo_node;
+
+#endif
+/* end of file */
diff --git a/include/rtems/posix/psignalimpl.h b/include/rtems/posix/psignalimpl.h
new file mode 100644
index 0000000000..d7e1afab70
--- /dev/null
+++ b/include/rtems/posix/psignalimpl.h
@@ -0,0 +1,152 @@
+/**
+ * @file
+ *
+ * @brief POSIX Signals Support
+ *
+ * This include file defines internal information about POSIX signals.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2013.
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_PSIGNALIMPL_H
+#define _RTEMS_POSIX_PSIGNALIMPL_H
+
+/**
+ * @defgroup POSIX_SIGNALS POSIX Signals Support
+ *
+ * @ingroup POSIXAPI
+ *
+ * @brief Internal Information about POSIX Signals
+ *
+ */
+/**@{**/
+
+#include <rtems/posix/psignal.h>
+#include <rtems/posix/pthread.h>
+#include <rtems/posix/sigset.h>
+#include <rtems/score/apiext.h>
+#include <rtems/score/isrlock.h>
+#include <rtems/score/percpu.h>
+#include <rtems/score/threadqimpl.h>
+
+#define _States_Is_interruptible_signal( _states ) \
+ ( ((_states) & \
+ (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL)) == \
+ (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL))
+
+#define SIGACTION_TERMINATE \
+ { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Abnormal_termination_handler} }
+#define SIGACTION_IGNORE \
+ { 0, SIGNAL_ALL_MASK, {SIG_IGN} }
+#define SIGACTION_STOP \
+ { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Stop_handler} }
+#define SIGACTION_CONTINUE \
+ { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Continue_handler} }
+
+#define SIG_ARRAY_MAX (SIGRTMAX + 1)
+
+/*
+ * Variables
+ */
+
+extern sigset_t _POSIX_signals_Pending;
+
+extern const struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ];
+
+extern struct sigaction _POSIX_signals_Vectors[ SIG_ARRAY_MAX ];
+
+extern Thread_queue_Control _POSIX_signals_Wait_queue;
+
+extern Chain_Control _POSIX_signals_Inactive_siginfo;
+
+extern Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
+
+/*
+ * Internal routines
+ */
+
+/**
+ * @brief POSIX signals manager initialization.
+ */
+void _POSIX_signals_Manager_Initialization(void);
+
+#define _POSIX_signals_Acquire( lock_context ) \
+ _Thread_queue_Acquire( &_POSIX_signals_Wait_queue, lock_context )
+
+#define _POSIX_signals_Release( lock_context ) \
+ _Thread_queue_Release( &_POSIX_signals_Wait_queue, lock_context )
+
+void _POSIX_signals_Action_handler(
+ Thread_Control *executing,
+ Thread_Action *action,
+ Per_CPU_Control *cpu,
+ ISR_Level level
+);
+
+/**
+ * @brief Unlock POSIX signals thread.
+ */
+bool _POSIX_signals_Unblock_thread(
+ Thread_Control *the_thread,
+ int signo,
+ siginfo_t *info
+);
+
+/**
+ * @brief Check POSIX signal.
+ */
+bool _POSIX_signals_Check_signal(
+ POSIX_API_Control *api,
+ int signo,
+ bool is_global
+);
+
+/**
+ * @brief Clear POSIX signals.
+ */
+bool _POSIX_signals_Clear_signals(
+ POSIX_API_Control *api,
+ int signo,
+ siginfo_t *info,
+ bool is_global,
+ bool check_blocked,
+ bool do_signals_acquire_release
+);
+
+int killinfo(
+ pid_t pid,
+ int sig,
+ const union sigval *value
+);
+
+/**
+ * @brief Set POSIX process signals.
+ */
+void _POSIX_signals_Set_process_signals(
+ sigset_t mask
+);
+
+void _POSIX_signals_Clear_process_signals(
+ int signo
+);
+
+/*
+ * Default signal handlers
+ */
+
+#define _POSIX_signals_Stop_handler NULL
+#define _POSIX_signals_Continue_handler NULL
+
+void _POSIX_signals_Abnormal_termination_handler( int signo );
+
+/** @} */
+
+#endif
+/* end of file */
diff --git a/include/rtems/posix/pthread.h b/include/rtems/posix/pthread.h
new file mode 100644
index 0000000000..05783ff4ad
--- /dev/null
+++ b/include/rtems/posix/pthread.h
@@ -0,0 +1,55 @@
+/**
+ * @file
+ *
+ * @brief POSIX Threads Private Support
+ *
+ * This include file contains all the private support information for
+ * POSIX threads.
+ */
+
+/*
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_PTHREAD_H
+#define _RTEMS_POSIX_PTHREAD_H
+
+#include <rtems/posix/config.h>
+#include <rtems/posix/threadsup.h>
+#include <rtems/score/thread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup POSIX_PTHREAD POSIX Threads Support
+ *
+ * @ingroup POSIXAPI
+ *
+ * @brief Private Support Information for POSIX Threads
+ *
+ */
+/**@{**/
+
+/**
+ * @brief POSIX threads initialize user threads body.
+ *
+ * This routine creates and starts all configured user
+ * initialization threads.
+ */
+extern void _POSIX_Threads_Initialize_user_threads_body(void);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/pthreadimpl.h b/include/rtems/posix/pthreadimpl.h
new file mode 100644
index 0000000000..f95ac9cf94
--- /dev/null
+++ b/include/rtems/posix/pthreadimpl.h
@@ -0,0 +1,238 @@
+/**
+ * @file
+ *
+ * @brief POSIX Threads Private Support
+ *
+ * This include file contains all the private support information for
+ * POSIX threads.
+ */
+
+/*
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_PTHREADIMPL_H
+#define _RTEMS_POSIX_PTHREADIMPL_H
+
+#include <rtems/posix/pthread.h>
+#include <rtems/posix/config.h>
+#include <rtems/posix/threadsup.h>
+#include <rtems/score/objectimpl.h>
+#include <rtems/score/threadimpl.h>
+#include <rtems/score/assert.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup POSIX_PTHREAD
+ */
+/**@{**/
+
+/**
+ * The following sets the minimum stack size for POSIX threads.
+ */
+#define PTHREAD_MINIMUM_STACK_SIZE (_Stack_Minimum() * 2)
+
+/**
+ * The following defines the information control block used to manage
+ * this class of objects.
+ */
+POSIX_EXTERN Thread_Information _POSIX_Threads_Information;
+
+/**
+ * This variable contains the default POSIX Thread attributes.
+ */
+extern pthread_attr_t _POSIX_Threads_Default_attributes;
+
+/**
+ * When the user configures a set of POSIX API initialization threads,
+ * This variable will point to the method used to initialize them.
+ *
+ * NOTE: It is instantiated and initialized by confdefs.h based upon
+ * application requirements.
+ */
+extern void (*_POSIX_Threads_Initialize_user_threads_p)(void);
+
+/**
+ * @brief POSIX threads manager initialization.
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+void _POSIX_Threads_Manager_initialization(void);
+
+/**
+ * @brief Copy POSIX Thread attribute structure.
+ *
+ * This routine copies the attr2 thread attribute structure
+ * to the attr1 Thread Attribute structure.
+ *
+ * @param[in] dst_attr is a pointer to the thread attribute
+ * structure to copy into.
+ *
+ * @param[out] src_attr is a pointer to the thread attribute
+ * structure to copy from.
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Threads_Copy_attributes(
+ pthread_attr_t *dst_attr,
+ const pthread_attr_t *src_attr
+);
+
+/**
+ * @brief Free POSIX control block.
+ *
+ * This routine frees a pthread control block to the
+ * inactive chain of free pthread control blocks.
+ *
+ * @param[in] the_pthread is a pointer to the thread to free.
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free(
+ Thread_Control *the_pthread
+);
+
+/**
+ * @brief POSIX threads initialize user threads body.
+ *
+ * This routine initializes the thread attributes structure.
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes(
+ pthread_attr_t *attr
+);
+
+/**
+ * @brief POSIX threads sporadic budget callout.
+ *
+ * This routine handles the sporadic scheduling algorithm.
+ *
+ * @param[in] the_thread is a pointer to the thread whose budget
+ * has been exceeded.
+ */
+void _POSIX_Threads_Sporadic_budget_callout(
+ Thread_Control *the_thread
+);
+
+/**
+ * This routine supports the sporadic scheduling algorithm. It
+ * is scheduled to be executed at the end of each replenishment
+ * period. In sporadic scheduling a thread will execute at a
+ * high priority for a user specified amount of CPU time. When
+ * it exceeds that amount of CPU time, its priority is automatically
+ * lowered. This TSR is executed when it is time to replenish
+ * the thread's processor budget and raise its priority.
+ *
+ * @param[in] id is ignored
+ * @param[in] argument is a pointer to the Thread_Control structure
+ * for the thread being replenished.
+ */
+void _POSIX_Threads_Sporadic_budget_TSR(
+ Objects_Id id,
+ void *argument
+);
+
+/**
+ * @brief Translate sched_param into SuperCore terms.
+ *
+ * This method translates the POSIX API sched_param into the corresponding
+ * SuperCore settings.
+ *
+ * @param[in] policy is the POSIX scheduling policy
+ * @param[in] param points to the scheduling parameter structure
+ * @param[in] budget_algorithm points to the output CPU Budget algorithm
+ * @param[in] budget_callout points to the output CPU Callout
+ *
+ * @retval 0 Indicates success.
+ * @retval error_code POSIX error code indicating failure.
+ */
+int _POSIX_Thread_Translate_sched_param(
+ int policy,
+ struct sched_param *param,
+ Thread_CPU_budget_algorithms *budget_algorithm,
+ Thread_CPU_budget_algorithm_callout *budget_callout
+);
+
+/*
+ * rtems_pthread_attribute_compare
+ */
+int rtems_pthread_attribute_compare(
+ const pthread_attr_t *attr1,
+ const pthread_attr_t *attr2
+);
+
+RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Allocate(void)
+{
+ _Objects_Allocator_lock();
+
+ _Thread_Kill_zombies();
+
+ return (Thread_Control *)
+ _Objects_Allocate_unprotected( &_POSIX_Threads_Information.Objects );
+}
+
+/*
+ * _POSIX_Threads_Copy_attributes
+ */
+
+RTEMS_INLINE_ROUTINE void _POSIX_Threads_Copy_attributes(
+ pthread_attr_t *dst_attr,
+ const pthread_attr_t *src_attr
+)
+{
+ *dst_attr = *src_attr;
+#if defined(RTEMS_SMP) && defined(__RTEMS_HAVE_SYS_CPUSET_H__)
+ _Assert(
+ dst_attr->affinitysetsize == sizeof(dst_attr->affinitysetpreallocated)
+ );
+ dst_attr->affinityset = &dst_attr->affinitysetpreallocated;
+#endif
+}
+
+/*
+ * _POSIX_Threads_Free
+ */
+
+RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free (
+ Thread_Control *the_pthread
+)
+{
+ _Objects_Free( &_POSIX_Threads_Information.Objects, &the_pthread->Object );
+}
+
+/*
+ * _POSIX_Threads_Initialize_attributes
+ */
+
+RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes(
+ pthread_attr_t *attr
+)
+{
+ _POSIX_Threads_Copy_attributes(
+ attr,
+ &_POSIX_Threads_Default_attributes
+ );
+}
+
+/*
+ * _POSIX_Threads_Is_null
+ */
+
+RTEMS_INLINE_ROUTINE bool _POSIX_Threads_Is_null (
+ Thread_Control *the_pthread
+)
+{
+ return !the_pthread;
+}
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/ptimer.h b/include/rtems/posix/ptimer.h
new file mode 100644
index 0000000000..16ac2b8373
--- /dev/null
+++ b/include/rtems/posix/ptimer.h
@@ -0,0 +1,95 @@
+/**
+ * @file
+ *
+ * @brief POSIX Timers Private Support
+ *
+ * This include file contains all the private support information for
+ * POSIX timers.
+ */
+
+/*
+ * Initial Implementation:
+ * COPYRIGHT (c) 1998. Alfonso Escalera PiƱa
+ * Largely rewritten by Joel Sherrill (1999).
+ *
+ * COPYRIGHT (c) 1999-2013.
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_PTIMER_H
+#define _RTEMS_POSIX_PTIMER_H
+
+/**
+ * @defgroup POSIX_PRIV_TIMERS POSIX Timers
+ *
+ * @ingroup POSIXAPI
+ */
+/**@{**/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/posix/config.h>
+
+/**
+ * @brief POSIX Timer Manager Initialization
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+void _POSIX_Timer_Manager_initialization(void);
+
+/**
+ * @brief Create a Per-Process Timer
+ */
+int timer_create(
+ clockid_t clock_id,
+ struct sigevent *evp,
+ timer_t *timerid
+);
+
+/**
+ * @brief Delete a Per-Process Timer
+ */
+int timer_delete(
+ timer_t timerid
+);
+
+/**
+ * @brief Set a Per-Process Timer
+ */
+int timer_settime(
+ timer_t timerid,
+ int flags,
+ const struct itimerspec *value,
+ struct itimerspec *ovalue
+);
+
+/**
+ * @brief Set a Per-Process Timer
+ */
+int timer_gettime(
+ timer_t timerid,
+ struct itimerspec *value
+);
+
+/**
+ * @brief Get overrun count for a Per-Process Timer
+ *
+ * The expiration of a timer must increase by one a counter.
+ * After the signal handler associated to the timer finishes
+ * its execution, _POSIX_Timer_TSR will have to set this counter to 0.
+ */
+int timer_getoverrun(
+ timer_t timerid
+);
+
+#ifdef __cplusplus
+}
+#endif
+/** @} */
+
+#endif /* _RTEMS_POSIX_PTIMER_H */
diff --git a/include/rtems/posix/rwlock.h b/include/rtems/posix/rwlock.h
new file mode 100644
index 0000000000..3d33d40915
--- /dev/null
+++ b/include/rtems/posix/rwlock.h
@@ -0,0 +1,63 @@
+/**
+ * @file
+ *
+ * @brief Constants and Structures Associated with the POSIX RWLock Manager
+ *
+ * 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-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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_RWLOCK_H
+#define _RTEMS_POSIX_RWLOCK_H
+
+#include <rtems/score/object.h>
+#include <rtems/score/corerwlock.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup POSIX_RWLOCK POSIX RWLock Manager
+ *
+ * @ingroup POSIXAPI
+ *
+ * @brief Constants and Structures Associated with the POSIX RWLock Manager
+ *
+ */
+/**@{**/
+
+/**
+ * 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;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/rwlockimpl.h b/include/rtems/posix/rwlockimpl.h
new file mode 100644
index 0000000000..46e33904dc
--- /dev/null
+++ b/include/rtems/posix/rwlockimpl.h
@@ -0,0 +1,106 @@
+/**
+ * @file
+ *
+ * @brief Inlined Routines from the POSIX RWLock Manager
+ *
+ * This file contains the static inlin implementation of the inlined
+ * routines from the POSIX RWLock Manager.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_RWLOCKIMPL_H
+#define _RTEMS_POSIX_RWLOCKIMPL_H
+
+#include <rtems/posix/rwlock.h>
+#include <rtems/score/corerwlockimpl.h>
+#include <rtems/score/objectimpl.h>
+
+#include <pthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * 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.
+ */
+
+void _POSIX_RWLock_Manager_initialization(void);
+
+/**
+ * @brief POSIX 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
+ * @retval 0 The status indicates that the operation completed successfully.
+ * @retval EINVAL The status indicates that the thread was blocked waiting for
+ * an operation to complete and the RWLock was deleted.
+ * @retval EBUSY This status indicates that the RWLock was not
+ * immediately available.
+ * @retval ETIMEDOUT This status indicates that the calling task was
+ * willing to block but the operation was unable to complete within
+ * the time allotted because the resource never became available.
+ */
+int _POSIX_RWLock_Translate_core_RWLock_return_code(
+ CORE_RWLock_Status the_RWLock_status
+);
+
+/**
+ * @brief Allocate a RWLock control block.
+ *
+ * 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 Free a RWLock control block.
+ *
+ * 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
+)
+{
+ _CORE_RWLock_Destroy( &the_RWLock->RWLock );
+ _Objects_Free( &_POSIX_RWLock_Information, &the_RWLock->Object );
+}
+
+POSIX_RWLock_Control *_POSIX_RWLock_Get(
+ pthread_rwlock_t *rwlock,
+ Objects_Locations *location
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/semaphore.h b/include/rtems/posix/semaphore.h
new file mode 100644
index 0000000000..5aef39b7ec
--- /dev/null
+++ b/include/rtems/posix/semaphore.h
@@ -0,0 +1,67 @@
+/**
+ * @file
+ *
+ * @brief Private Support Information for POSIX Semaphores
+ *
+ * This include file contains all the private support information for
+ * POSIX Semaphores.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_SEMAPHORE_H
+#define _RTEMS_POSIX_SEMAPHORE_H
+
+#include <semaphore.h>
+#include <rtems/score/object.h>
+#include <rtems/score/coresem.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup POSIXSemaphorePrivate POSIX Semaphore Private Support
+ *
+ * @ingroup POSIXAPI
+ *
+ * This defines the internal implementation support for POSIX semaphores.
+ */
+/**@{*/
+
+/*
+ * Data Structure used to manage a POSIX semaphore
+ */
+
+typedef struct {
+ Objects_Control Object;
+ int process_shared;
+ bool named;
+ bool linked;
+ uint32_t open_count;
+ CORE_semaphore_Control Semaphore;
+ /*
+ * sem_t is 32-bit. If Object_Id is 16-bit, then they are not
+ * interchangeable. We have to be able to return a pointer to
+ * a 32-bit form of the 16-bit Id.
+ */
+ #if defined(RTEMS_USE_16_BIT_OBJECT)
+ sem_t Semaphore_id;
+ #endif
+} POSIX_Semaphore_Control;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/semaphoreimpl.h b/include/rtems/posix/semaphoreimpl.h
new file mode 100644
index 0000000000..eeea51c488
--- /dev/null
+++ b/include/rtems/posix/semaphoreimpl.h
@@ -0,0 +1,191 @@
+/**
+ * @file
+ *
+ * @brief Private Inlined Routines for POSIX Semaphores
+ *
+ * This include file contains the static inline implementation of the private
+ * inlined routines for POSIX Semaphores.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2013.
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_SEMAPHOREIMPL_H
+#define _RTEMS_POSIX_SEMAPHOREIMPL_H
+
+#include <rtems/posix/semaphore.h>
+#include <rtems/posix/posixapi.h>
+#include <rtems/score/coresemimpl.h>
+
+#include <errno.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * This defines the information control block used to manage
+ * this class of objects.
+ */
+POSIX_EXTERN Objects_Information _POSIX_Semaphore_Information;
+
+/**
+ * This defines the mapping from Score status codes to POSIX return codes.
+ */
+extern const int
+ _POSIX_Semaphore_Return_codes[CORE_SEMAPHORE_STATUS_LAST + 1];
+
+/**
+ * @brief POSIX Semaphore Manager Initialization
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+void _POSIX_Semaphore_Manager_initialization(void);
+
+RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *
+ _POSIX_Semaphore_Allocate_unprotected( void )
+{
+ return (POSIX_Semaphore_Control *)
+ _Objects_Allocate_unprotected( &_POSIX_Semaphore_Information );
+}
+
+/**
+ * @brief POSIX Semaphore Free
+ *
+ * This routine frees a semaphore control block to the
+ * inactive chain of free semaphore control blocks.
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free (
+ POSIX_Semaphore_Control *the_semaphore
+)
+{
+ _CORE_semaphore_Destroy( &the_semaphore->Semaphore );
+ _Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object );
+}
+
+/**
+ * @brief POSIX Semaphore Get
+ *
+ * This function maps semaphore IDs to semaphore control blocks.
+ * If ID corresponds to a local semaphore, then it returns
+ * the_semaphore control pointer which maps to ID and location
+ * is set to OBJECTS_LOCAL. if the semaphore ID is global and
+ * resides on a remote node, then location is set to OBJECTS_REMOTE,
+ * and the_semaphore is undefined. Otherwise, location is set
+ * to OBJECTS_ERROR and the_semaphore is undefined.
+ */
+RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get (
+ sem_t *id,
+ Objects_Locations *location
+)
+{
+ return (POSIX_Semaphore_Control *)
+ _Objects_Get( &_POSIX_Semaphore_Information, (Objects_Id)*id, location );
+}
+
+RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *
+_POSIX_Semaphore_Get_interrupt_disable(
+ sem_t *id,
+ Objects_Locations *location,
+ ISR_lock_Context *lock_context
+)
+{
+ return (POSIX_Semaphore_Control *) _Objects_Get_isr_disable(
+ &_POSIX_Semaphore_Information,
+ (Objects_Id)*id,
+ location,
+ lock_context
+ );
+}
+
+/**
+ * @brief POSIX Semaphore Create Support
+ *
+ * This routine supports the sem_init and sem_open routines.
+ */
+
+int _POSIX_Semaphore_Create_support(
+ const char *name,
+ size_t name_len,
+ int pshared,
+ unsigned int value,
+ POSIX_Semaphore_Control **the_sem
+);
+
+/**
+ * @brief POSIX Semaphore Delete
+ *
+ * This routine supports the sem_close and sem_unlink routines.
+ */
+void _POSIX_Semaphore_Delete(
+ POSIX_Semaphore_Control *the_semaphore
+);
+
+/**
+ * @brief POSIX semaphore wait support.
+ *
+ * This routine supports the sem_wait, sem_trywait, and sem_timedwait
+ * services.
+ */
+int _POSIX_Semaphore_Wait_support(
+ sem_t *sem,
+ bool blocking,
+ Watchdog_Interval timeout
+);
+
+/**
+ * @brief POSIX Semaphore Translate Score to POSIX Return Codes
+ *
+ * A support routine which converts core semaphore status codes into the
+ * appropriate POSIX status values.
+ */
+RTEMS_INLINE_ROUTINE int
+_POSIX_Semaphore_Translate_core_semaphore_return_code(
+ CORE_semaphore_Status the_semaphore_status
+)
+{
+ /*
+ * Internal consistency check for bad status from SuperCore
+ */
+ #if defined(RTEMS_DEBUG)
+ if ( the_semaphore_status > CORE_SEMAPHORE_STATUS_LAST )
+ return EINVAL;
+ #endif
+ return _POSIX_Semaphore_Return_codes[the_semaphore_status];
+}
+
+/**
+ * @brief POSIX Semaphore Namespace Remove
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove (
+ POSIX_Semaphore_Control *the_semaphore
+)
+{
+ _Objects_Namespace_remove(
+ &_POSIX_Semaphore_Information, &the_semaphore->Object );
+}
+
+/**
+ * @see _POSIX_Name_to_id().
+ */
+RTEMS_INLINE_ROUTINE int _POSIX_Semaphore_Name_to_id(
+ const char *name,
+ Objects_Id *id,
+ size_t *len
+)
+{
+ return _POSIX_Name_to_id( &_POSIX_Semaphore_Information, name, id, len );
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/sigset.h b/include/rtems/posix/sigset.h
new file mode 100644
index 0000000000..96bcc086ba
--- /dev/null
+++ b/include/rtems/posix/sigset.h
@@ -0,0 +1,45 @@
+/**
+ * @file
+ *
+ * @brief POSIX Signal Sets Management Helper
+ *
+ * This file defines the interface to implementation helper for management
+ * of POSIX Signal Sets.
+ */
+
+/*
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_SIGSET_H
+#define _RTEMS_POSIX_SIGSET_H
+
+#include <signal.h> // sigset_t
+
+/*
+ * Currently 32 signals numbered 1-32 are defined
+ */
+
+#define SIGNAL_EMPTY_MASK 0x00000000L
+#define SIGNAL_ALL_MASK 0xffffffffL
+
+static inline sigset_t signo_to_mask(
+ uint32_t sig
+)
+{
+ return 1u << (sig - 1);
+}
+
+static inline bool is_valid_signo(
+ int signo
+)
+{
+ return ((signo) >= 1 && (signo) <= 32 );
+}
+
+#endif
diff --git a/include/rtems/posix/spinlock.h b/include/rtems/posix/spinlock.h
new file mode 100644
index 0000000000..8da451ce22
--- /dev/null
+++ b/include/rtems/posix/spinlock.h
@@ -0,0 +1,63 @@
+/**
+ * @file
+ *
+ * @brief POSIX Spinlock Support
+ *
+ * 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-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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_SPINLOCK_H
+#define _RTEMS_POSIX_SPINLOCK_H
+
+#include <rtems/score/object.h>
+#include <rtems/score/corespinlock.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup POSIX_SPINLOCK POSIX Spinlock Support
+ *
+ * @ingroup POSIXAPI
+ *
+ * @brief Constants and Structures Associated with the POSIX Spinlock Manager
+ *
+ */
+/**@{**/
+
+/**
+ * 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;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/spinlockimpl.h b/include/rtems/posix/spinlockimpl.h
new file mode 100644
index 0000000000..8a2f58360d
--- /dev/null
+++ b/include/rtems/posix/spinlockimpl.h
@@ -0,0 +1,114 @@
+/**
+ * @file
+ *
+ * @brief Inlined Routines from the POSIX Spinlock Manager
+ *
+ * This file contains the static inlin implementation of the inlined
+ * routines from the POSIX Spinlock Manager.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_SPINLOCKIMPL_H
+#define _RTEMS_POSIX_SPINLOCKIMPL_H
+
+#include <rtems/posix/spinlock.h>
+#include <rtems/score/corespinlockimpl.h>
+#include <rtems/score/objectimpl.h>
+
+#include <pthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * The following defines the information control block used to manage
+ * this class of objects.
+ */
+
+POSIX_EXTERN Objects_Information _POSIX_Spinlock_Information;
+
+/**
+ * @brief POSIX spinlock manager initialization.
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+
+void _POSIX_Spinlock_Manager_initialization(void);
+
+/**
+ * @brief Translate core spinlock status code.
+ *
+ * This routine translates SuperCore Spinlock status codes into the
+ * corresponding POSIX ones.
+ *
+ * @param[in] the_spinlock_status is the SuperCore status.
+ *
+ * @return the corresponding POSIX status
+ */
+int _POSIX_Spinlock_Translate_core_spinlock_return_code(
+ CORE_spinlock_Status the_spinlock_status
+);
+
+/**
+ * @brief Allocate a spinlock control block.
+ *
+ * This function allocates a spinlock control block from
+ * the inactive chain of free spinlock control blocks.
+ */
+RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Allocate( void )
+{
+ return (POSIX_Spinlock_Control *)
+ _Objects_Allocate( &_POSIX_Spinlock_Information );
+}
+
+/**
+ * @brief Free a spinlock control block.
+ *
+ * This routine frees a spinlock control block to the
+ * inactive chain of free spinlock control blocks.
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Spinlock_Free (
+ POSIX_Spinlock_Control *the_spinlock
+)
+{
+ _Objects_Free( &_POSIX_Spinlock_Information, &the_spinlock->Object );
+}
+
+/**
+ * @brief Get a spinlock control block.
+ *
+ * This function maps spinlock IDs to spinlock control blocks.
+ * If ID corresponds to a local spinlock, then it returns
+ * the_spinlock control pointer which maps to ID and location
+ * is set to OBJECTS_LOCAL. if the spinlock ID is global and
+ * resides on a remote node, then location is set to OBJECTS_REMOTE,
+ * and the_spinlock is undefined. Otherwise, location is set
+ * to OBJECTS_ERROR and the_spinlock is undefined.
+ */
+RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Get (
+ pthread_spinlock_t *spinlock,
+ Objects_Locations *location
+)
+{
+ return (POSIX_Spinlock_Control *) _Objects_Get(
+ &_POSIX_Spinlock_Information,
+ (Objects_Id) *spinlock,
+ location
+ );
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/threadsup.h b/include/rtems/posix/threadsup.h
new file mode 100644
index 0000000000..ae122962bc
--- /dev/null
+++ b/include/rtems/posix/threadsup.h
@@ -0,0 +1,121 @@
+/**
+ * @file
+ *
+ * @brief POSIX Thread API Support
+ *
+ * This defines the POSIX thread API extension.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2014.
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_THREADSUP_H
+#define _RTEMS_POSIX_THREADSUP_H
+
+#include <rtems/score/coresem.h>
+#include <rtems/score/thread.h>
+#include <rtems/score/threadq.h>
+#include <rtems/score/watchdog.h>
+
+#include <pthread.h>
+#include <signal.h>
+
+/**
+ * @defgroup POSIX_THREAD POSIX Thread API Extension
+ *
+ * @ingroup POSIXAPI
+ *
+ */
+/**@{**/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * This defines the POSIX API support structure associated with
+ * each thread in a system with POSIX configured.
+ */
+typedef struct {
+ /** This is the POSIX threads attribute set. */
+ pthread_attr_t Attributes;
+ /** This indicates whether the thread is attached or detached. */
+ int detachstate;
+ /** This is the set of threads waiting for the thread to exit. */
+ Thread_queue_Control Join_List;
+ /** This is the thread's current scheduling policy. */
+ int schedpolicy;
+ /** This is the thread's current set of scheduling parameters. */
+ struct sched_param schedparam;
+ /**
+ * This is the high priority to execute at when using the sporadic
+ * scheduler.
+ */
+ int ss_high_priority;
+ /**
+ * This is the timer which controls when the thread executes at
+ * high and low priority when using the sporadic scheduler.
+ */
+ Watchdog_Control Sporadic_timer;
+
+ /** This is the set of signals which are currently blocked. */
+ sigset_t signals_blocked;
+ /** This is the set of signals which are currently pending. */
+ sigset_t signals_pending;
+
+ /**
+ * @brief Signal post-switch action in case signals are pending.
+ */
+ Thread_Action Signal_action;
+
+ /*******************************************************************/
+ /*******************************************************************/
+ /*************** POSIX Cancelability ***************/
+ /*******************************************************************/
+ /*******************************************************************/
+
+ /** This is the cancelability state. */
+ int cancelability_state;
+ /** This is the cancelability type. */
+ int cancelability_type;
+ /** This indicates if a cancelation has been requested. */
+ int cancelation_requested;
+ /**
+ * @brief LIFO list of cleanup contexts.
+ */
+ struct _pthread_cleanup_context *last_cleanup_context;
+} POSIX_API_Control;
+
+/**
+ * @brief POSIX thread exit shared helper.
+ *
+ * 16.1.5.1 Thread Termination, p1003.1c/Draft 10, p. 150
+ *
+ * This method is a helper routine which ensures that all
+ * POSIX thread calls which result in a thread exiting will
+ * do so in the same manner.
+ *
+ * @param[in] the_thread is a pointer to the thread exiting or being canceled
+ * @param[in] value_ptr is a pointer the value to be returned by the thread
+ *
+ * NOTE: Key destructors are executed in the POSIX api delete extension.
+ *
+ */
+void _POSIX_Thread_Exit(
+ Thread_Control *the_thread,
+ void *value_ptr
+);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/timer.h b/include/rtems/posix/timer.h
new file mode 100644
index 0000000000..79fe093219
--- /dev/null
+++ b/include/rtems/posix/timer.h
@@ -0,0 +1,60 @@
+/**
+ * @file
+ *
+ * @brief POSIX Timers Internal Support
+ *
+ * This include files defines the internal support for implementation of
+ * POSIX Timers.
+ */
+
+/*
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_TIMER_H
+#define _RTEMS_POSIX_TIMER_H
+
+#include <rtems/score/object.h>
+#include <rtems/score/watchdog.h>
+
+#include <pthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup POSIX_INTERNAL_TIMERS POSIX Timer Private Support
+ *
+ * @ingroup POSIXAPI
+ */
+/**@{*/
+
+/*
+ * Data for a timer
+ */
+typedef struct {
+ Objects_Control Object;
+ Watchdog_Control Timer; /* Internal Timer */
+ pthread_t thread_id; /* Thread identifier */
+ char state; /* State of the timer */
+ struct sigevent inf; /* Information associated to the timer */
+ struct itimerspec timer_data; /* Timing data of the timer */
+ uint32_t ticks; /* Number of ticks of the initialization */
+ uint32_t overrun; /* Number of expirations of the timer */
+ struct timespec time; /* Time at which the timer was started */
+} POSIX_Timer_Control;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/include/rtems/posix/timerimpl.h b/include/rtems/posix/timerimpl.h
new file mode 100644
index 0000000000..b297d3205a
--- /dev/null
+++ b/include/rtems/posix/timerimpl.h
@@ -0,0 +1,131 @@
+/**
+ * @file
+ *
+ * @brief Inlined Routines from the POSIX Timer Manager
+ *
+ * This file contains the static inline implementation of the inlined routines
+ * from the POSIX Timer Manager.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2013.
+ * 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.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_TIMERIMPL_H
+#define _RTEMS_POSIX_TIMERIMPL_H
+
+#include <rtems/posix/timer.h>
+#include <rtems/score/objectimpl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Timer is free */
+#define POSIX_TIMER_STATE_FREE 0x01
+
+/** Created timer but not running */
+#define POSIX_TIMER_STATE_CREATE_NEW 0x02
+
+/** Created timer and running */
+#define POSIX_TIMER_STATE_CREATE_RUN 0x03
+
+/** Created, ran and stopped timer */
+#define POSIX_TIMER_STATE_CREATE_STOP 0x04
+
+/** Indicates that the fire time is relative to the current one */
+#define POSIX_TIMER_RELATIVE 0
+
+/*
+ * POSIX defines TIMER_ABSTIME but no constant for relative. So
+ * we have one internally but we need to be careful it has a different
+ * value.
+ */
+#if (POSIX_TIMER_RELATIVE == TIMER_ABSTIME)
+#error "POSIX_TIMER_RELATIVE == TIMER_ABSTIME"
+#endif
+
+/**
+ * @brief POSIX Timer Manager Initialization
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+void _POSIX_Timer_Manager_initialization(void);
+
+/**
+ * @brief POSIX Timer Manager Timer Service Routine Helper
+ *
+ * This is the operation that is run when a timer expires.
+ */
+void _POSIX_Timer_TSR(Objects_Id timer, void *data);
+
+/**
+ * @brief POSIX Timer Watchdog Insertion Helper
+ */
+bool _POSIX_Timer_Insert_helper(
+ Watchdog_Control *timer,
+ Watchdog_Interval ticks,
+ Objects_Id id,
+ Watchdog_Service_routine_entry TSR,
+ void *arg
+);
+
+/**
+ * The following defines the information control block used to manage
+ * this class of objects.
+ */
+POSIX_EXTERN Objects_Information _POSIX_Timer_Information;
+
+/**
+ * @brief POSIX Timer Allocate
+ *
+ * This function allocates a timer control block from
+ * the inactive chain of free timer control blocks.
+ */
+RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void )
+{
+ return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information );
+}
+
+/**
+ * @brief POSIX Timer Free
+ *
+ * This routine frees a timer control block to the
+ * inactive chain of free timer control blocks.
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free (
+ POSIX_Timer_Control *the_timer
+)
+{
+ _Objects_Free( &_POSIX_Timer_Information, &the_timer->Object );
+}
+
+/**
+ * @brief POSIX Timer Get
+ *
+ * This function maps timer IDs to timer control blocks.
+ * If ID corresponds to a local timer, then it returns
+ * the timer control pointer which maps to ID and location
+ * is set to OBJECTS_LOCAL. Otherwise, location is set
+ * to OBJECTS_ERROR and the returned value is undefined.
+ */
+RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get (
+ timer_t id,
+ Objects_Locations *location
+)
+{
+ return (POSIX_Timer_Control *)
+ _Objects_Get( &_POSIX_Timer_Information, (Objects_Id) id, location );
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */