summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/include/rtems
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/posix/include/rtems')
-rw-r--r--cpukit/posix/include/rtems/posix/aio_misc.h108
-rw-r--r--cpukit/posix/include/rtems/posix/barrier.h88
-rw-r--r--cpukit/posix/include/rtems/posix/cancel.h62
-rw-r--r--cpukit/posix/include/rtems/posix/cond.h181
-rw-r--r--cpukit/posix/include/rtems/posix/config.h77
-rw-r--r--cpukit/posix/include/rtems/posix/key.h103
-rw-r--r--cpukit/posix/include/rtems/posix/mqueue.h248
-rw-r--r--cpukit/posix/include/rtems/posix/mutex.h192
-rw-r--r--cpukit/posix/include/rtems/posix/posixapi.h30
-rw-r--r--cpukit/posix/include/rtems/posix/priority.h91
-rw-r--r--cpukit/posix/include/rtems/posix/psignal.h121
-rw-r--r--cpukit/posix/include/rtems/posix/pthread.h175
-rw-r--r--cpukit/posix/include/rtems/posix/ptimer.h94
-rw-r--r--cpukit/posix/include/rtems/posix/rwlock.h88
-rw-r--r--cpukit/posix/include/rtems/posix/semaphore.h198
-rw-r--r--cpukit/posix/include/rtems/posix/sigset.h42
-rw-r--r--cpukit/posix/include/rtems/posix/spinlock.h88
-rw-r--r--cpukit/posix/include/rtems/posix/threadsup.h95
-rw-r--r--cpukit/posix/include/rtems/posix/time.h59
-rw-r--r--cpukit/posix/include/rtems/posix/timer.h107
20 files changed, 2247 insertions, 0 deletions
diff --git a/cpukit/posix/include/rtems/posix/aio_misc.h b/cpukit/posix/include/rtems/posix/aio_misc.h
new file mode 100644
index 0000000000..c90d509d44
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/aio_misc.h
@@ -0,0 +1,108 @@
+/*
+ * 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.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+
+#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/cpukit/posix/include/rtems/posix/barrier.h b/cpukit/posix/include/rtems/posix/barrier.h
new file mode 100644
index 0000000000..6bb2aa2e5c
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/barrier.h
@@ -0,0 +1,88 @@
+/**
+ * @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-2008.
+ * 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(void);
+
+/**
+ * @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/cancel.h b/cpukit/posix/include/rtems/posix/cancel.h
new file mode 100644
index 0000000000..6e6b32a71c
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/cancel.h
@@ -0,0 +1,62 @@
+/**
+ * @file rtems/posix/cancel.h
+ *
+ * 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.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#ifndef _RTEMS_POSIX_CANCEL_H
+#define _RTEMS_POSIX_CANCEL_H
+
+#include <rtems/posix/threadsup.h>
+
+/**
+ * This structure is used to manage the cancelation handlers.
+ */
+typedef struct {
+ /** This field is the Chain Node so we can put these on lists. */
+ Chain_Node Node;
+ /** This field is the cancelation routine. */
+ void (*routine)( void * );
+ /** This field is the argument to the cancelation routine. */
+ void *arg;
+} POSIX_Cancel_Handler_control;
+
+/**
+ * @brief _POSIX_Threads_cancel_run
+ *
+ * This support routine runs through the chain of cancel handlers that
+ * have been registered and executes them.
+ *
+ * @param[in] the_thread is the thread whose cancelation handlers
+ * should be run
+ */
+void _POSIX_Threads_cancel_run(
+ Thread_Control *the_thread
+);
+
+/**
+ * @brief _POSIX_Thread_Evaluate_cancellation_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 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/cpukit/posix/include/rtems/posix/cond.h b/cpukit/posix/include/rtems/posix/cond.h
new file mode 100644
index 0000000000..5ed8dfeed7
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/cond.h
@@ -0,0 +1,181 @@
+/**
+ * @file rtems/posix/cond.h
+ */
+
+/*
+ * This include file contains all the private support information for
+ * POSIX condition variables.
+ *
+ * COPYRIGHT (c) 1989-2008.
+ * 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_COND_H
+#define _RTEMS_POSIX_COND_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/score/object.h>
+#include <rtems/score/threadq.h>
+
+/*
+ * Constant to indicate condition variable does not currently have
+ * a mutex assigned to it.
+ */
+
+#define POSIX_CONDITION_VARIABLES_NO_MUTEX 0
+
+/*
+ * Data Structure used to manage a POSIX condition variable
+ */
+
+typedef struct {
+ Objects_Control Object;
+ int process_shared;
+ pthread_mutex_t Mutex;
+ Thread_queue_Control Wait_queue;
+} POSIX_Condition_variables_Control;
+
+/*
+ * The following defines the information control block used to manage
+ * this class of objects.
+ */
+
+POSIX_EXTERN Objects_Information _POSIX_Condition_variables_Information;
+
+/*
+ * The default condition variable attributes structure.
+ */
+
+extern const pthread_condattr_t _POSIX_Condition_variables_Default_attributes;
+
+/*
+ * _POSIX_Condition_variables_Manager_initialization
+ *
+ * DESCRIPTION:
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+
+void _POSIX_Condition_variables_Manager_initialization(void);
+
+/*
+ * _POSIX_Condition_variables_Allocate
+ *
+ * DESCRIPTION:
+ *
+ * This function allocates a condition variable control block from
+ * the inactive chain of free condition variable control blocks.
+ */
+
+RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control *
+ _POSIX_Condition_variables_Allocate( void );
+
+/*
+ * _POSIX_Condition_variables_Free
+ *
+ * DESCRIPTION:
+ *
+ * This routine frees a condition variable control block to the
+ * inactive chain of free condition variable control blocks.
+ */
+
+RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Free (
+ POSIX_Condition_variables_Control *the_condition_variable
+);
+
+/*
+ * _POSIX_Condition_variables_Get
+ *
+ * DESCRIPTION:
+ *
+ * This function maps condition variable IDs to condition variable control
+ * blocks. If ID corresponds to a local condition variable, then it returns
+ * the_condition variable control pointer which maps to ID and location
+ * is set to OBJECTS_LOCAL. if the condition variable ID is global and
+ * resides on a remote node, then location is set to OBJECTS_REMOTE,
+ * and the_condition variable is undefined. Otherwise, location is set
+ * to OBJECTS_ERROR and the_condition variable is undefined.
+ */
+
+#if 0
+RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get (
+ Objects_Id *id,
+ Objects_Locations *location
+);
+#endif
+
+/*
+ * _POSIX_Condition_variables_Is_null
+ *
+ * DESCRIPTION:
+ *
+ * This function returns TRUE if the_condition variable is NULL
+ * and FALSE otherwise.
+ */
+
+RTEMS_INLINE_ROUTINE bool _POSIX_Condition_variables_Is_null (
+ POSIX_Condition_variables_Control *the_condition_variable
+);
+
+/*
+ * _POSIX_Condition_variables_Signal_support
+ *
+ * DESCRIPTION:
+ *
+ * A support routine which implements guts of the broadcast and single task
+ * wake up version of the "signal" operation.
+ */
+
+int _POSIX_Condition_variables_Signal_support(
+ pthread_cond_t *cond,
+ bool is_broadcast
+);
+
+/*
+ * _POSIX_Condition_variables_Wait_support
+ *
+ * DESCRIPTION:
+ *
+ * A support routine which implements guts of the blocking, non-blocking, and
+ * timed wait version of condition variable wait routines.
+ */
+
+int _POSIX_Condition_variables_Wait_support(
+ pthread_cond_t *cond,
+ pthread_mutex_t *mutex,
+ Watchdog_Interval timeout,
+ bool already_timedout
+);
+
+/*
+ * _POSIX_Condition_variables_Get
+ *
+ * DESCRIPTION:
+ *
+ * A support routine which translates the condition variable id into
+ * a local pointer. As a side-effect, it may create the condition
+ * variable.
+ */
+
+POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get (
+ pthread_cond_t *cond,
+ Objects_Locations *location
+);
+
+#include <rtems/posix/cond.inl>
+
+#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
new file mode 100644
index 0000000000..b6ad91fb34
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/config.h
@@ -0,0 +1,77 @@
+/**
+ * @file rtems/posix/config.h
+ *
+ * This include file contains the table of user defined configuration
+ * parameters specific for the POSIX API.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2008.
+ * 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_CONFIG_H
+#define _RTEMS_POSIX_CONFIG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * XXX
+ *
+ * The following records define the Configuration Table. The
+ * information contained in this table is required in all
+ * RTEMS systems, whether single or multiprocessor. This
+ * table primarily defines the following:
+ *
+ * + required number of each object type
+ */
+
+/*
+ * For now, we are only allowing the user to specify the entry point
+ * and stack size for POSIX initialization threads.
+ */
+
+typedef struct {
+ void *(*thread_entry)(void *);
+ int stack_size;
+} posix_initialization_threads_table;
+
+typedef struct {
+ int maximum_threads;
+ int maximum_mutexes;
+ int maximum_condition_variables;
+ int maximum_keys;
+ int maximum_timers;
+ int maximum_queued_signals;
+ int maximum_message_queues;
+ int maximum_message_queue_descriptors;
+ 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;
+
+/**
+ * @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/cpukit/posix/include/rtems/posix/key.h b/cpukit/posix/include/rtems/posix/key.h
new file mode 100644
index 0000000000..e39aa98d53
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/key.h
@@ -0,0 +1,103 @@
+/**
+ * @file rtems/posix/key.h
+ */
+
+/* rtems/posix/key.h
+ *
+ * This include file contains all the private support information for
+ * POSIX key.
+ *
+ * COPYRIGHT (c) 1989-2010.
+ * 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_KEY_H
+#define _RTEMS_POSIX_KEY_H
+
+#include <rtems/score/object.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * This is the data Structure used to manage a POSIX key.
+ *
+ * @note The Values is a table indexed by the index portion of the
+ * ID of the currently executing thread.
+ */
+typedef struct {
+ /** This field is the Object control structure. */
+ Objects_Control Object;
+ /** This field points to the optional destructor method. */
+ void (*destructor)( void * );
+ /** This field points to the values per thread. */
+ void **Values[ OBJECTS_APIS_LAST + 1 ];
+} POSIX_Keys_Control;
+
+/**
+ * The following defines the information control block used to manage
+ * this class of objects.
+ */
+POSIX_EXTERN Objects_Information _POSIX_Keys_Information;
+
+/**
+ * @brief _POSIX_Keys_Manager_initialization
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+void _POSIX_Key_Manager_initialization(void);
+
+/**
+ * @brief _POSIX_Keys_Run_destructors
+ *
+ * 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 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 Key Memory
+ *
+ * This memory frees the key table memory associated with @a the_key.
+ *
+ * @param[in] the_key is the POSIX key to free the table memory of.
+ */
+void _POSIX_Keys_Free_memory(
+ POSIX_Keys_Control *the_key
+);
+
+/**
+ * @brief _POSIX_Keys_Free
+ *
+ * This routine frees a keys control block to the
+ * inactive chain of free keys control blocks.
+ *
+ * @param[in] the_key is the POSIX key to free.
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free (
+ POSIX_Keys_Control *the_key
+);
+
+#include <rtems/posix/key.inl>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/posix/include/rtems/posix/mqueue.h b/cpukit/posix/include/rtems/posix/mqueue.h
new file mode 100644
index 0000000000..1e2e7a7429
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/mqueue.h
@@ -0,0 +1,248 @@
+/**
+ * @file rtems/posix/mqueue.h
+ *
+ * This include file contains all the private support information for
+ * POSIX Message Queues.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2008.
+ * 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_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
+
+/*
+ * 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;
+
+/*
+ * The following defines the information control block used to manage
+ * this class of objects. The second item is used to manage the set
+ * of "file descriptors" associated with the message queues.
+ */
+
+POSIX_EXTERN Objects_Information _POSIX_Message_queue_Information;
+POSIX_EXTERN Objects_Information _POSIX_Message_queue_Information_fds;
+
+/*
+ * _POSIX_Message_queue_Manager_initialization
+ *
+ * DESCRIPTION:
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+
+void _POSIX_Message_queue_Manager_initialization(void);
+
+/*
+ *
+ * _POSIX_Message_queue_Create_support
+ *
+ * DESCRIPTION:
+ *
+ * This routine performs the creation of a message queue utilizing the
+ * core message queue.
+ */
+
+int _POSIX_Message_queue_Create_support(
+ const char *name,
+ int pshared,
+ struct mq_attr *attr,
+ POSIX_Message_queue_Control **message_queue
+);
+
+/*
+ * _POSIX_Message_queue_Delete
+ *
+ * DESCRIPTION:
+ *
+ * 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
+);
+
+/*
+ * _POSIX_Message_queue_Receive_support
+ *
+ * DESCRIPTION:
+ *
+ * This routine supports the various flavors of receiving a message.
+ */
+
+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
+);
+
+/*
+ * _POSIX_Message_queue_Send_support
+ *
+ * DESCRIPTION:
+ *
+ * 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,
+ uint32_t msg_prio,
+ bool wait,
+ Watchdog_Interval timeout
+);
+
+/*
+ * _POSIX_Message_queue_Allocate
+ *
+ * DESCRIPTION:
+ *
+ * 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 );
+
+/*
+ * _POSIX_Message_queue_Free
+ *
+ * DESCRIPTION:
+ *
+ * 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
+);
+
+/*
+ * _POSIX_Message_queue_Get
+ *
+ * DESCRIPTION:
+ *
+ * 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
+);
+
+/*
+ * _POSIX_Message_queue_Is_null
+ *
+ * DESCRIPTION:
+ *
+ * This function returns TRUE if the_message_queue is NULL and FALSE otherwise.
+ */
+
+RTEMS_INLINE_ROUTINE bool _POSIX_Message_queue_Is_null (
+ POSIX_Message_queue_Control *the_mq
+);
+
+/*
+ * _POSIX_Message_queue_Name_to_id
+ *
+ * DESCRIPTION:
+ *
+ * This routine looks up the specified name for a message queue and returns the
+ * id of the message queue associated with it.
+ */
+
+int _POSIX_Message_queue_Name_to_id(
+ const char *name,
+ Objects_Id *id
+);
+
+/*
+ * _POSIX_Message_queue_Priority_to_core
+ *
+ * DESCRIPTION:
+ *
+ * XXX
+ */
+
+RTEMS_INLINE_ROUTINE CORE_message_queue_Submit_types _POSIX_Message_queue_Priority_to_core(
+ unsigned int priority
+);
+
+/*
+ * _POSIX_Message_queue_Priority_from_core
+ *
+ * DESCRIPTION:
+ *
+ * XXX
+ */
+
+RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core(
+ CORE_message_queue_Submit_types priority
+);
+
+/*PAGE
+ *
+ * _POSIX_Message_queue_Translate_core_message_queue_return_code
+ *
+ * DESCRIPTION:
+ *
+ * XXX
+ */
+
+int _POSIX_Message_queue_Translate_core_message_queue_return_code(
+ uint32_t the_message_queue_status
+);
+
+
+#include <rtems/posix/mqueue.inl>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/posix/include/rtems/posix/mutex.h b/cpukit/posix/include/rtems/posix/mutex.h
new file mode 100644
index 0000000000..4309edfaa8
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/mutex.h
@@ -0,0 +1,192 @@
+/**
+ * @file rtems/posix/mutex.h
+ */
+
+/*
+ * This include file contains all the private support information for
+ * POSIX mutex's.
+ *
+ * COPYRIGHT (c) 1989-2008.
+ * 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_MUTEX_H
+#define _RTEMS_POSIX_MUTEX_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/score/coremutex.h>
+#include <pthread.h>
+
+/*
+ * Data Structure used to manage a POSIX mutex
+ */
+
+typedef struct {
+ Objects_Control Object;
+ int process_shared;
+ CORE_mutex_Control Mutex;
+} POSIX_Mutex_Control;
+
+/*
+ * 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;
+
+/*
+ * _POSIX_Mutex_Manager_initialization
+ *
+ * DESCRIPTION:
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+
+void _POSIX_Mutex_Manager_initialization(void);
+
+/*
+ * _POSIX_Mutex_Allocate
+ *
+ * DESCRIPTION:
+ *
+ * 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 );
+
+/*
+ * _POSIX_Mutex_Free
+ *
+ * DESCRIPTION:
+ *
+ * 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
+);
+
+#if 0
+/*
+ * _POSIX_Mutex_Get
+ *
+ * DESCRIPTION:
+ *
+ * This function maps mutexes IDs to mutexes control blocks.
+ * If ID corresponds to a local mutexes, then it returns
+ * the_mutex control pointer which maps to ID and location
+ * is set to OBJECTS_LOCAL. if the mutexes ID is global and
+ * resides on a remote node, then location is set to OBJECTS_REMOTE,
+ * and the_mutex is undefined. Otherwise, location is set
+ * to OBJECTS_ERROR and the_mutex is undefined.
+ */
+
+RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get (
+ Objects_Id *id,
+ Objects_Locations *location
+);
+
+/*
+ * _POSIX_Mutex_Is_null
+ *
+ * DESCRIPTION:
+ *
+ * This function returns TRUE if the_mutex is NULL and FALSE otherwise.
+ */
+
+RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_null (
+ POSIX_Mutex_Control *the_mutex
+);
+#endif
+
+/*
+ * _POSIX_Mutex_Lock_support
+ *
+ * DESCRIPTION:
+ *
+ * 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
+);
+
+/*
+ * _POSIX_Mutex_Translate_core_mutex_return_code
+ *
+ * DESCRIPTION:
+ *
+ * A support routine which converts core mutex status codes into the
+ * appropriate POSIX status values.
+ */
+
+int _POSIX_Mutex_Translate_core_mutex_return_code(
+ CORE_mutex_Status the_mutex_status
+);
+
+
+/*
+ * _POSIX_Mutex_Get
+ *
+ * DESCRIPTION:
+ *
+ * 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
+);
+
+/*
+ * _POSIX_Mutex_Get
+ *
+ * DESCRIPTION:
+ *
+ * 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_Level *level
+);
+
+#include <rtems/posix/mutex.inl>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h
new file mode 100644
index 0000000000..729a6db163
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/posixapi.h
@@ -0,0 +1,30 @@
+/**
+ * @file rtems/posix/posixapi.h
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2008.
+ * 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_POSIXAPI_H
+#define _RTEMS_POSIX_POSIXAPI_H
+
+#include <rtems/config.h>
+
+/**
+ * @brief Initialize POSIX API
+ *
+ * This method is responsible for initializing each of the POSIX
+ * API managers.
+ */
+void _POSIX_API_Initialize(void);
+
+#endif
+/* end of include file */
diff --git a/cpukit/posix/include/rtems/posix/priority.h b/cpukit/posix/include/rtems/posix/priority.h
new file mode 100644
index 0000000000..5944c4e7c3
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/priority.h
@@ -0,0 +1,91 @@
+/**
+ * @file rtems/posix/priority.h
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2008.
+ * 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_PRIORITY_H
+#define _RTEMS_POSIX_PRIORITY_H
+
+#include <rtems/score/priority.h>
+
+/**
+ * 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)
+
+/**
+ * 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
+ *
+ * @return This method returns true if the priority is valid and
+ * false otherwise.
+ */
+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
+);
+
+/**
+ * @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
+);
+
+#include <rtems/posix/priority.inl>
+
+#endif
diff --git a/cpukit/posix/include/rtems/posix/psignal.h b/cpukit/posix/include/rtems/posix/psignal.h
new file mode 100644
index 0000000000..87b629ef52
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/psignal.h
@@ -0,0 +1,121 @@
+/**
+ * @file rtems/posix/psignal.h
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2008.
+ * 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_PSIGNAL_H
+#define _RTEMS_POSIX_PSIGNAL_H
+
+#include <rtems/posix/pthread.h>
+#include <rtems/posix/sigset.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 Watchdog_Control _POSIX_signals_Alarm_timer;
+
+extern Watchdog_Control _POSIX_signals_Ualarm_timer;
+
+extern Thread_queue_Control _POSIX_signals_Wait_queue;
+
+extern Chain_Control _POSIX_signals_Inactive_siginfo;
+
+extern Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
+
+/*
+ * POSIX internal siginfo structure
+ */
+
+typedef struct {
+ Chain_Node Node;
+ siginfo_t Info;
+} POSIX_signals_Siginfo_node;
+
+/*
+ * Internal routines
+ */
+
+void _POSIX_signals_Manager_Initialization(void);
+
+void _POSIX_signals_Post_switch_extension(
+ Thread_Control *the_thread
+);
+
+bool _POSIX_signals_Unblock_thread(
+ Thread_Control *the_thread,
+ int signo,
+ siginfo_t *info
+);
+
+bool _POSIX_signals_Check_signal(
+ POSIX_API_Control *api,
+ int signo,
+ bool is_global
+);
+
+bool _POSIX_signals_Clear_signals(
+ POSIX_API_Control *api,
+ int signo,
+ siginfo_t *info,
+ bool is_global,
+ bool check_blocked
+);
+
+int killinfo(
+ pid_t pid,
+ int sig,
+ const union sigval *value
+);
+
+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/cpukit/posix/include/rtems/posix/pthread.h b/cpukit/posix/include/rtems/posix/pthread.h
new file mode 100644
index 0000000000..6185afa62c
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/pthread.h
@@ -0,0 +1,175 @@
+/**
+ * @file rtems/posix/pthread.h
+ */
+
+/*
+ * This include file contains all the private support information for
+ * POSIX threads.
+ *
+ * COPYRIGHT (c) 1989-2008.
+ * 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_PTHREAD_H
+#define _RTEMS_POSIX_PTHREAD_H
+
+
+#include <rtems/posix/config.h>
+#include <rtems/posix/threadsup.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**
+ * 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 Objects_Information _POSIX_Threads_Information;
+
+/**
+ * This variable contains the default POSIX Thread attributes.
+ */
+extern const 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 _POSIX_Threads_Allocate
+ *
+ * This function allocates a pthread control block from
+ * the inactive chain of free pthread control blocks.
+ *
+ * @return This method returns a newly allocated thread.
+ */
+RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Allocate( void );
+
+/**
+ * @brief _POSIX_Threads_Free
+ *
+ * This routine frees a pthread control block to the
+ * inactive chain of free pthread control blocks.
+ *
+ * @param[in] the_pthread is the thread to free
+ */
+RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free(
+ Thread_Control *the_pthread
+);
+
+/**
+ * @brief _POSIX_Threads_Get
+ *
+ * This function maps pthread IDs to pthread control blocks.
+ * If ID corresponds to a local pthread, then it returns
+ * the_pthread control pointer which maps to ID and location
+ * is set to OBJECTS_LOCAL. if the pthread ID is global and
+ * resides on a remote node, then location is set to OBJECTS_REMOTE,
+ * and the_pthread is undefined. Otherwise, location is set
+ * to OBJECTS_ERROR and the_pthread is undefined.
+ *
+ * @param[in] id is the id to lookup
+ * @param[in] location points to the returned location value
+ *
+ * @return This methods returns a pointer to the corresponding Thread_Control.
+ */
+RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Get(
+ pthread_t id,
+ Objects_Locations *location
+);
+
+/**
+ * @brief _POSIX_Threads_Is_null
+ *
+ * This function returns TRUE if the_pthread is NULL and FALSE otherwise.
+ *
+ * @param[in] the_pthread is the thread pointer to check.
+ *
+ * @return This method returns true if the thread pointer is null.
+ */
+RTEMS_INLINE_ROUTINE bool _POSIX_Threads_Is_null(
+ Thread_Control *the_pthread
+);
+
+/**
+ * @brief _POSIX_Threads_Sporadic_budget_callout
+ *
+ * This routine handles the sporadic scheduling algorithm.
+ *
+ * @param[in] the_thread is the thread whose budget has been exceeded.
+ */
+void _POSIX_Threads_Sporadic_budget_callout(
+ Thread_Control *the_thread
+);
+
+/**
+ * _POSIX_Threads_Sporadic_budget_TSR
+ *
+ * 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
+ *
+ * @return This method returns 0 on success or a POSIX error code.
+ */
+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
+);
+
+#include <rtems/posix/pthread.inl>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/posix/include/rtems/posix/ptimer.h b/cpukit/posix/include/rtems/posix/ptimer.h
new file mode 100644
index 0000000000..79fba9d819
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/ptimer.h
@@ -0,0 +1,94 @@
+/**
+ * @file rtems/posix/ptimer.h
+ */
+
+/* rtems/posix/ptimer.h
+ *
+ * This include file contains all the private support information for
+ * POSIX timers.
+ *
+ * COPYRIGHT (c) 1998.
+ * Alfonso Escalera PiƱa
+ *
+ * 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.
+ *
+ * ptimer.h,v 1.0 1998/03/31 16:21:16
+ */
+
+#ifndef _RTEMS_POSIX_PTIMER_H
+#define _RTEMS_POSIX_PTIMER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/posix/config.h>
+
+/*
+ * _POSIX_Timers_Manager_initialization
+ *
+ * DESCRIPTION:
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+
+void _POSIX_Timer_Manager_initialization(void);
+
+/*
+ * 14.2.2 Create a Per-Process Timer, P1003.1b-1993, p. 264
+ *
+ * timer_create
+ */
+
+int timer_create(
+ clockid_t clock_id,
+ struct sigevent *evp,
+ timer_t *timerid
+);
+
+/*
+ * 14.2.3 Delete a Per_process Timer, P1003.1b-1993, p. 266
+ */
+
+int timer_delete(
+ timer_t timerid
+);
+
+/*
+ * 14.2.4 Per-Process Timers, P1003.1b-1993, p. 267
+ *
+ * timer_settime
+ */
+
+int timer_settime(
+ timer_t timerid,
+ int flags,
+ const struct itimerspec *value,
+ struct itimerspec *ovalue
+);
+
+/*
+ * 14.2.4 Per-Process Timers, P1003.1b-1993, p. 267
+ *
+ * timer_gettime
+ */
+
+int timer_gettime(
+ timer_t timerid,
+ struct itimerspec *value
+);
+
+/*
+ * 14.2.4 Per-Process Timers, P1003.1b-1993, p. 267
+ *
+ * timer_getoverrun
+ *
+ */
+
+int timer_getoverrun(
+ timer_t timerid
+);
+
+#endif
diff --git a/cpukit/posix/include/rtems/posix/rwlock.h b/cpukit/posix/include/rtems/posix/rwlock.h
new file mode 100644
index 0000000000..2774e02379
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/rwlock.h
@@ -0,0 +1,88 @@
+/**
+ * @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-2008.
+ * 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(void);
+
+/**
+ * @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/semaphore.h b/cpukit/posix/include/rtems/posix/semaphore.h
new file mode 100644
index 0000000000..5f232eea54
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/semaphore.h
@@ -0,0 +1,198 @@
+/**
+ * @file rtems/posix/semaphore.h
+ */
+
+/* rtems/posix/semaphore.h
+ *
+ * This include file contains all the private support information for
+ * POSIX Semaphores.
+ *
+ * COPYRIGHT (c) 1989-2008.
+ * 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_SEMAPHORE_H
+#define _RTEMS_POSIX_SEMAPHORE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <semaphore.h>
+#include <rtems/score/coresem.h>
+
+/*
+ * 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;
+
+/*
+ * The following defines the information control block used to manage
+ * this class of objects.
+ */
+
+POSIX_EXTERN Objects_Information _POSIX_Semaphore_Information;
+
+/*
+ * _POSIX_Semaphore_Manager_initialization
+ *
+ * DESCRIPTION:
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+
+void _POSIX_Semaphore_Manager_initialization(void);
+
+/*
+ * _POSIX_Semaphore_Allocate
+ *
+ * DESCRIPTION:
+ *
+ * This function allocates a semaphore control block from
+ * the inactive chain of free semaphore control blocks.
+ */
+
+RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Allocate( void );
+
+/*
+ * _POSIX_Semaphore_Free
+ *
+ * DESCRIPTION:
+ *
+ * This routine frees a semaphore control block to the
+ * inactive chain of free semaphore control blocks.
+ */
+
+RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free (
+ POSIX_Semaphore_Control *the_semaphore
+);
+
+/*
+ * _POSIX_Semaphore_Get
+ *
+ * DESCRIPTION:
+ *
+ * This function maps semaphore IDs to semaphore control blocks.
+ * If ID corresponds to a local semaphore, then it returns
+ * the_semaphore control pointer which maps to ID and location
+ * is set to OBJECTS_LOCAL. if the semaphore ID is global and
+ * resides on a remote node, then location is set to OBJECTS_REMOTE,
+ * and the_semaphore is undefined. Otherwise, location is set
+ * to OBJECTS_ERROR and the_semaphore is undefined.
+ */
+
+RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get (
+ sem_t *id,
+ Objects_Locations *location
+);
+
+/*
+ * _POSIX_Semaphore_Is_null
+ *
+ * DESCRIPTION:
+ *
+ * This function returns TRUE if the_semaphore is NULL and FALSE otherwise.
+ */
+
+RTEMS_INLINE_ROUTINE bool _POSIX_Semaphore_Is_null (
+ POSIX_Semaphore_Control *the_semaphore
+);
+
+/*
+ * _POSIX_Semaphore_Create_support
+ *
+ * DESCRIPTION:
+ *
+ * This routine supports the sem_init and sem_open routines.
+ */
+
+int _POSIX_Semaphore_Create_support(
+ const char *name,
+ int pshared,
+ unsigned int value,
+ POSIX_Semaphore_Control **the_sem
+);
+
+/*
+ * _POSIX_Semaphore_Delete
+ *
+ * DESCRIPTION:
+ *
+ * This routine supports the sem_close and sem_unlink routines.
+ */
+
+void _POSIX_Semaphore_Delete(
+ POSIX_Semaphore_Control *the_semaphore
+);
+
+/*
+ * _POSIX_Semaphore_Wait_support
+ *
+ * DESCRIPTION:
+ *
+ * This routine supports the sem_wait, sem_trywait, and sem_timedwait
+ * services.
+ */
+
+int _POSIX_Semaphore_Wait_support(
+ sem_t *sem,
+ bool blocking,
+ Watchdog_Interval timeout
+);
+
+/*
+ * _POSIX_Semaphore_Name_to_id
+ *
+ * DESCRIPTION:
+ *
+ * This routine performs name to id translation.
+ */
+
+int _POSIX_Semaphore_Name_to_id(
+ const char *name,
+ sem_t *id
+);
+
+/*
+ * _POSIX_Semaphore_Translate_core_semaphore_return_code
+ *
+ * DESCRIPTION:
+ *
+ * A support routine which converts core semaphore status codes into the
+ * appropriate POSIX status values.
+ */
+
+int _POSIX_Semaphore_Translate_core_semaphore_return_code(
+ CORE_semaphore_Status the_semaphore_status
+);
+
+#include <rtems/posix/semaphore.inl>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/posix/include/rtems/posix/sigset.h b/cpukit/posix/include/rtems/posix/sigset.h
new file mode 100644
index 0000000000..338879e5e2
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/sigset.h
@@ -0,0 +1,42 @@
+/**
+ * @file rtems/posix/sigset.h
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2008.
+ * 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_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/cpukit/posix/include/rtems/posix/spinlock.h b/cpukit/posix/include/rtems/posix/spinlock.h
new file mode 100644
index 0000000000..cf6cb6fbd2
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/spinlock.h
@@ -0,0 +1,88 @@
+/**
+ * @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-2008.
+ * 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(void);
+
+/**
+ * @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/threadsup.h b/cpukit/posix/include/rtems/posix/threadsup.h
new file mode 100644
index 0000000000..cc3a87e99a
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/threadsup.h
@@ -0,0 +1,95 @@
+/**
+ * @file rtems/posix/threadsup.h
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2008.
+ * 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_THREADSUP_H
+#define _RTEMS_POSIX_THREADSUP_H
+
+#include <sys/signal.h>
+#include <rtems/score/coresem.h>
+#include <rtems/score/tqdata.h>
+
+#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;
+
+ /*******************************************************************/
+ /*******************************************************************/
+ /*************** 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;
+ /** This is the set of cancelation handlers. */
+ Chain_Control Cancellation_Handlers;
+
+} POSIX_API_Control;
+
+/*!
+ * @brief POSIX Thread Exit Shared Helper
+ *
+ * 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 the thread exiting or being canceled
+ * @param[in] value_ptr is the value to be returned by the thread
+ */
+void _POSIX_Thread_Exit(
+ Thread_Control *the_thread,
+ void *value_ptr
+);
+
+#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
new file mode 100644
index 0000000000..93e3af0f44
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/time.h
@@ -0,0 +1,59 @@
+/**
+ * @file rtems/posix/time.h
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2008.
+ * 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_TIME_H
+#define _RTEMS_POSIX_TIME_H
+
+#include <rtems/score/timespec.h>
+#include <rtems/score/watchdog.h>
+
+/** @brief Absolute Timeout Conversion Results
+ *
+ * This enumeration defines the possible results of converting
+ * an absolute time used for timeouts to POSIX blocking calls to
+ * a number of ticks.
+ */
+typedef enum {
+ /** The timeout is invalid. */
+ POSIX_ABSOLUTE_TIMEOUT_INVALID,
+ /** The timeout represents a time that is in the past. */
+ POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST,
+ /** The timeout represents a time that is equal to the current time. */
+ POSIX_ABSOLUTE_TIMEOUT_IS_NOW,
+ /** The timeout represents a time that is in the future. */
+ POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE,
+} POSIX_Absolute_timeout_conversion_results_t;
+
+/**
+ * @brief Convert Absolute Timeout to Ticks
+ *
+ * This method takes an absolute time being used as a timeout
+ * to a blocking directive, validates it and returns the number
+ * of corresponding clock ticks for use by the SuperCore.
+ *
+ * @param[in] abstime is the timeout
+ * @param[in] ticks_out will contain the number of ticks
+ *
+ * @return This method returns the number of ticks in @a ticks_out
+ * and a status value indicating whether the absolute time
+ * is valid, in the past, equal to the current time or in
+ * the future as it should be.
+ */
+POSIX_Absolute_timeout_conversion_results_t _POSIX_Absolute_timeout_to_ticks(
+ const struct timespec *abstime,
+ Watchdog_Interval *ticks_out
+);
+
+#endif
diff --git a/cpukit/posix/include/rtems/posix/timer.h b/cpukit/posix/include/rtems/posix/timer.h
new file mode 100644
index 0000000000..c061e9d6b7
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/timer.h
@@ -0,0 +1,107 @@
+/**
+ * @file rtems/posix/timer.h
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2008.
+ * 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_TIMER_H
+#define _RTEMS_POSIX_TIMER_H
+
+#include <rtems/posix/config.h>
+#include <rtems/score/object.h>
+#include <rtems/score/watchdog.h> /* Watchdog_Control */
+
+#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
+
+
+/*
+ * 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;
+
+/*
+ * _POSIX_Timers_Manager_initialization
+ *
+ * DESCRIPTION:
+ *
+ * This routine performs the initialization necessary for this manager.
+ */
+void _POSIX_Timer_Manager_initialization(void);
+
+/*
+ * Timer TSR
+ */
+void _POSIX_Timer_TSR(Objects_Id timer, void *data);
+
+/*
+ * Watchdog Insert 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;
+
+#ifndef __RTEMS_APPLICATION__
+#include <rtems/posix/timer.inl>
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */