[PATCH v2 43/44] config: Add <rtems/confdefs/objectsposix.h>

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Feb 21 10:52:55 UTC 2020


Remove all comments and copyrightable content from the moved content.
Use BSD-2-Clause license for new file.

Update #3053.
Update #3875.
---
 cpukit/headers.am                            |   1 +
 cpukit/include/rtems/confdefs.h              | 200 +--------------------------
 cpukit/include/rtems/confdefs/objectsposix.h | 197 ++++++++++++++++++++++++++
 3 files changed, 200 insertions(+), 198 deletions(-)
 create mode 100644 cpukit/include/rtems/confdefs/objectsposix.h

diff --git a/cpukit/headers.am b/cpukit/headers.am
index 5b189a6641..cebab504e9 100644
--- a/cpukit/headers.am
+++ b/cpukit/headers.am
@@ -197,6 +197,7 @@ include_rtems_confdefs_HEADERS += include/rtems/confdefs/malloc.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/mpci.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/newlib.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/objectsclassic.h
+include_rtems_confdefs_HEADERS += include/rtems/confdefs/objectsposix.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/obsolete.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/percpu.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/scheduler.h
diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index 97e5b6d9fb..fe3b26ce86 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -30,13 +30,6 @@
 #include <rtems/score/apimutex.h>
 #include <rtems/score/context.h>
 #include <rtems/score/wkspace.h>
-#include <rtems/posix/key.h>
-#include <rtems/posix/mqueue.h>
-#include <rtems/posix/psignal.h>
-#include <rtems/posix/pthread.h>
-#include <rtems/posix/semaphore.h>
-#include <rtems/posix/shm.h>
-#include <rtems/posix/timer.h>
 #include <rtems/confdefs/obsolete.h>
 #include <rtems/confdefs/bdbuf.h>
 #include <rtems/confdefs/clock.h>
@@ -51,6 +44,7 @@
 #include <rtems/confdefs/mpci.h>
 #include <rtems/confdefs/newlib.h>
 #include <rtems/confdefs/objectsclassic.h>
+#include <rtems/confdefs/objectsposix.h>
 #include <rtems/confdefs/percpu.h>
 #include <rtems/confdefs/scheduler.h>
 #include <rtems/confdefs/threads.h>
@@ -115,122 +109,6 @@ extern "C" {
 #endif
 /**@}*/
 
-/**
- * @defgroup ConfigurationPOSIXAPI POSIX API Configuration Parameters
- *
- * This module contains the parameters related to configuration
- * of the POSIX API services.
- */
-/**@{*/
-
-/**
- * This configuration parameter specifies the maximum number of
- * POSIX API keys.
- *
- * POSIX Keys are available whether or not the POSIX API is enabled.
- */
-#ifndef CONFIGURE_MAXIMUM_POSIX_KEYS
-  #define CONFIGURE_MAXIMUM_POSIX_KEYS 0
-#endif
-
-/*
- * This macro is calculated to specify the memory required for
- * POSIX API key/value pairs.
- */
-#ifndef CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS
-  #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \
-    (CONFIGURE_MAXIMUM_POSIX_KEYS * \
-     (CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_TASKS))
-#endif
-
-/*
- * Account for the object control structures plus the name
- * of the object to be duplicated.
- */
-#define _Configure_POSIX_Named_Object_RAM(_number, _size) \
-  (rtems_resource_maximum_per_allocation(_number) \
-    * _Configure_From_workspace(_POSIX_PATH_MAX + 1))
-
-/**
- * This configuration parameter specifies the maximum number of
- * POSIX API message queues.
- */
-#ifndef CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES
-  #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 0
-#endif
-
-/*
- * This macro is calculated to specify the memory required for
- * POSIX API message queues.
- */
-#define _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES(_message_queues) \
-  _Configure_POSIX_Named_Object_RAM( \
-     _message_queues, sizeof(POSIX_Message_queue_Control) )
-
-/**
- * This configuration parameter specifies the maximum number of
- * POSIX API semaphores.
- */
-#ifndef CONFIGURE_MAXIMUM_POSIX_SEMAPHORES
-  #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 0
-#endif
-
-/*
- * This macro is calculated to specify the memory required for
- * POSIX API semaphores.
- */
-#define _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES(_semaphores) \
-  _Configure_POSIX_Named_Object_RAM( \
-     _semaphores, sizeof(POSIX_Semaphore_Control) )
-
-/**
- * Configure the maximum number of POSIX shared memory objects.
- */
-#ifndef CONFIGURE_MAXIMUM_POSIX_SHMS
-  #define CONFIGURE_MAXIMUM_POSIX_SHMS 0
-#endif
-
-/*
- * This macro is calculated to specify the memory required for
- * POSIX API shared memory.
- */
-#define _CONFIGURE_MEMORY_FOR_POSIX_SHMS(_shms) \
-  _Configure_POSIX_Named_Object_RAM(_shms, sizeof(POSIX_Shm_Control) )
-
-/**
- * This configuration parameter specifies the maximum number of
- * POSIX API timers.
- */
-#ifndef CONFIGURE_MAXIMUM_POSIX_TIMERS
-  #define CONFIGURE_MAXIMUM_POSIX_TIMERS 0
-#endif
-
-#if !defined(RTEMS_POSIX_API) && CONFIGURE_MAXIMUM_POSIX_TIMERS != 0
-  #error "CONFIGURE_MAXIMUM_POSIX_TIMERS must be zero if POSIX API is disabled"
-#endif
-
-/**
- * This configuration parameter specifies the maximum number of
- * POSIX API queued signals.
- */
-#ifndef CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS
-  #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 0
-#endif
-
-#if !defined(RTEMS_POSIX_API) && CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS != 0
-  #error "CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS must be zero if POSIX API is disabled"
-#endif
-
-#if CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS > 0
-  #define _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS \
-    _Configure_From_workspace( (CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS) * \
-      sizeof( POSIX_signals_Siginfo_node ) )
-#else
-  #define _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS 0
-#endif
-
-/**@}*/  /* end of POSIX API Configuration */
-
 /**
  * This is so we can account for tasks with stacks greater than minimum
  * size.  This is in bytes.
@@ -294,13 +172,7 @@ extern "C" {
  */
 #define CONFIGURE_EXECUTIVE_RAM_SIZE \
 ( \
-   _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( \
-     CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES) + \
-   _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \
-     CONFIGURE_MAXIMUM_POSIX_SEMAPHORES) + \
-   _CONFIGURE_MEMORY_FOR_POSIX_SHMS( \
-     CONFIGURE_MAXIMUM_POSIX_SHMS) + \
-   _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS + \
+   _CONFIGURE_MEMORY_FOR_POSIX_OBJECTS + \
    CONFIGURE_MESSAGE_BUFFER_MEMORY + \
    (CONFIGURE_MEMORY_OVERHEAD * 1024) + \
    _CONFIGURE_HEAP_HANDLER_OVERHEAD \
@@ -357,50 +229,6 @@ extern "C" {
   )
 
 #ifdef CONFIGURE_INIT
-  #if CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS > 0
-    POSIX_Keys_Key_value_pair _POSIX_Keys_Key_value_pairs[
-      rtems_resource_maximum_per_allocation(
-        CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS
-      )
-    ];
-
-    const uint32_t _POSIX_Keys_Key_value_pair_maximum =
-      CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS;
-  #endif
-
-  #if CONFIGURE_MAXIMUM_POSIX_KEYS > 0
-    POSIX_KEYS_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_KEYS );
-  #endif
-
-  #if CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES > 0
-    POSIX_MESSAGE_QUEUE_INFORMATION_DEFINE(
-      CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES
-    );
-  #endif
-
-  #if CONFIGURE_MAXIMUM_POSIX_SEMAPHORES > 0
-    POSIX_SEMAPHORE_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_SEMAPHORES );
-  #endif
-
-  #if CONFIGURE_MAXIMUM_POSIX_SHMS > 0
-    POSIX_SHM_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_SHMS );
-  #endif
-
-  #ifdef RTEMS_POSIX_API
-    #if CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS > 0
-      const uint32_t _POSIX_signals_Maximum_queued_signals =
-        CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS;
-
-      POSIX_signals_Siginfo_node _POSIX_signals_Siginfo_nodes[
-        CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS
-      ];
-    #endif
-
-    #if CONFIGURE_MAXIMUM_POSIX_TIMERS > 0
-      POSIX_TIMER_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_TIMERS );
-    #endif
-  #endif
-
   /**
    * This variable specifies the minimum stack size for tasks in an RTEMS
    * application.
@@ -468,29 +296,5 @@ extern "C" {
 }
 #endif
 
-/******************************************************************
- ******************************************************************
- ******************************************************************
- *         CONFIGURATION WARNINGS AND ERROR CHECKING              *
- ******************************************************************
- ******************************************************************
- ******************************************************************
- */
-
-#ifdef CONFIGURE_INIT
-
-/*
- * POSIX Key pair shouldn't be less than POSIX Key, which is highly
- * likely to be error.
- */
-#if (CONFIGURE_MAXIMUM_POSIX_KEYS != 0) && \
-    (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS != 0)
-  #if (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS < CONFIGURE_MAXIMUM_POSIX_KEYS)
-    #error "Fewer POSIX Key pairs than POSIX Key!"
-  #endif
-#endif
-
-#endif /* CONFIGURE_INIT */
-
 #endif
 /* end of include file */
diff --git a/cpukit/include/rtems/confdefs/objectsposix.h b/cpukit/include/rtems/confdefs/objectsposix.h
new file mode 100644
index 0000000000..d4322d0fca
--- /dev/null
+++ b/cpukit/include/rtems/confdefs/objectsposix.h
@@ -0,0 +1,197 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSApplicationConfiguration
+ *
+ * @brief Evaluate POSIX API Objects Configuration Options
+ *
+ * For the POSIX thread objects configuration see <rtems/confdefs/threads.h>.
+ */
+
+#ifndef _RTEMS_CONFDEFS_OBJECTSPOSIX_H
+#define _RTEMS_CONFDEFS_OBJECTSPOSIX_H
+
+#ifndef __CONFIGURATION_TEMPLATE_h
+#error "Do not include this file directly, use <rtems/confdefs.h> instead"
+#endif
+
+#ifdef CONFIGURE_INIT
+
+#include <rtems/confdefs/threads.h>
+#include <rtems/confdefs/wkspacesupport.h>
+#include <rtems/config.h>
+
+#include <limits.h>
+
+#define _Configure_Memory_for_named_objects( _number, _size ) \
+  ( rtems_resource_maximum_per_allocation( _number ) \
+    * _Configure_From_workspace( _POSIX_PATH_MAX + 1 ) )
+
+#ifndef CONFIGURE_MAXIMUM_POSIX_KEYS
+  #define CONFIGURE_MAXIMUM_POSIX_KEYS 0
+#endif
+
+#ifndef CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS
+  #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \
+    ( CONFIGURE_MAXIMUM_POSIX_KEYS * \
+     ( CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_TASKS ) )
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_KEYS > 0 \
+  && CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS < CONFIGURE_MAXIMUM_POSIX_KEYS
+  #error "CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS must be greater than or equal to CONFIGURE_MAXIMUM_POSIX_KEYS"
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_KEYS == 0 \
+  && CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS > 0
+  #warning "If CONFIGURE_MAXIMUM_POSIX_KEYS is zero, then CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS should be zero as well"
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_KEYS > 0 || CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS > 0
+  #include <rtems/posix/key.h>
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES > 0
+  #include <rtems/posix/mqueue.h>
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS > 0
+  #include <rtems/posix/psignal.h>
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_SEMAPHORES > 0
+  #include <rtems/posix/semaphore.h>
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_SHMS > 0
+  #include <rtems/posix/shm.h>
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_TIMERS > 0
+  #include <rtems/posix/timer.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_KEYS > 0
+  POSIX_KEYS_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_KEYS );
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS > 0
+  POSIX_Keys_Key_value_pair _POSIX_Keys_Key_value_pairs[
+    rtems_resource_maximum_per_allocation(
+      CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS
+    )
+  ];
+
+  const uint32_t _POSIX_Keys_Key_value_pair_maximum =
+    CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS;
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES > 0
+  POSIX_MESSAGE_QUEUE_INFORMATION_DEFINE(
+    CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES
+  );
+
+  #define _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES \
+    _Configure_Memory_for_named_objects( \
+       CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES, \
+       sizeof( POSIX_Message_queue_Control ) \
+     )
+#else
+  #define _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES 0
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_SEMAPHORES > 0
+  POSIX_SEMAPHORE_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_SEMAPHORES );
+
+  #define _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES \
+    _Configure_Memory_for_named_objects( \
+       CONFIGURE_MAXIMUM_POSIX_SEMAPHORES, \
+       sizeof( POSIX_Semaphore_Control ) \
+     )
+#else
+  #define _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES 0
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_SHMS > 0
+  POSIX_SHM_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_SHMS );
+
+  #define _CONFIGURE_MEMORY_FOR_POSIX_SHMS \
+    _Configure_Memory_for_named_objects( \
+       CONFIGURE_MAXIMUM_POSIX_SHMS, \
+       sizeof( POSIX_Shm_Control ) \
+     )
+#else
+  #define _CONFIGURE_MEMORY_FOR_POSIX_SHMS 0
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS > 0
+  #ifndef RTEMS_POSIX_API
+    #error "CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS must be zero if POSIX API is disabled"
+  #endif
+
+  const uint32_t _POSIX_signals_Maximum_queued_signals =
+    CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS;
+
+  POSIX_signals_Siginfo_node _POSIX_signals_Siginfo_nodes[
+    CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS
+  ];
+
+  #define _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS \
+    _Configure_From_workspace( CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS \
+      * sizeof( POSIX_signals_Siginfo_node ) )
+#else
+  #define _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS 0
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_TIMERS > 0
+  #ifndef RTEMS_POSIX_API
+    #error "CONFIGURE_MAXIMUM_POSIX_TIMERS must be zero if POSIX API is disabled"
+  #endif
+
+  POSIX_TIMER_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_TIMERS );
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define _CONFIGURE_MEMORY_FOR_POSIX_OBJECTS \
+  ( _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES \
+    + _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS \
+    + _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES \
+    + _CONFIGURE_MEMORY_FOR_POSIX_SHMS )
+
+#endif /* CONFIGURE_INIT */
+
+#endif /* _RTEMS_CONFDEFS_OBJECTSPOSIX_H */
-- 
2.16.4



More information about the devel mailing list